Skip to content

Commit

Permalink
0.0.443
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Sep 7, 2024
1 parent 6417dfa commit 595495f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
33 changes: 31 additions & 2 deletions imports/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,6 @@ export class Packager<L extends Link<any>> {
client: DeepClient<any>;
constructor(client: DeepClient<L>) {
this.client = client;
// @ts-ignore
global.packager = this;
}

/**
Expand Down Expand Up @@ -389,6 +387,35 @@ export class Packager<L extends Link<any>> {
return { ids: [], errors };
}

async update(packageId: Id, pckg: Package) {
const errors = [];
try {
this.validate(pckg, errors);
if (errors.length) return { errors };
const { data, counter, dependedLinks, packageId, namespaceId } = await this.deserialize(pckg, errors);
if (errors.length) return { errors };
const { sorted } = sort(pckg, data, errors, {
id: 'id',
from: 'from',
to: 'to',
type: 'type',
});
if (errors.length) return { errors };
const mutated = {};
const ids = await this.client.reserve(counter);
const { global, difference } = await this.globalizeIds(pckg, ids, sorted);
if (pckg.errors?.length) {
return { errors: pckg.errors };
}
console.log('update', { packageId, pckg, global, difference, ids, sorted, data });
} catch (e) {
log('import error');
const serializedError = serializeError(e);
; errors.push(serializedError);
}
return { ids: [], errors };
}

async selectLinks(options: PackagerExportOptions): Promise<MinilinksResult<PackagerLink>> {
const Contain = await this.client.id('@deep-foundation/core', 'Contain');
const Package = await this.client.id('@deep-foundation/core', 'Package');
Expand Down Expand Up @@ -680,6 +707,8 @@ export class Packager<L extends Link<any>> {
if (!!~alreadyIndex) {
return alreadyIndex;
} else {
if (!link?.contains?.[0]?.package?.value?.value) pckg.errors.push(`!link?.contains?.[0]?.package?.value?.value for ${link?.id}`);
if (!link?.contains?.[0]?.package?.versions?.[0]?.value?.value) pckg.errors.push(`!link?.contains?.[0]?.package?.versions?.[0]?.value?.value for ${link?.id}`);
dependencies.push({ name: link?.contains?.[0]?.package?.value?.value, version: link?.contains?.[0]?.package?.versions?.[0]?.value?.value });
return dependencies.length - 1;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deep-foundation/deeplinks",
"version": "0.0.442",
"version": "0.0.443",
"license": "Unlicense",
"type": "module",
"scripts": {
Expand Down

0 comments on commit 595495f

Please sign in to comment.