@things-factory/figure-library 10.1.153 → 10.1.155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/dist-client/pages/figure-library-page.d.ts +20 -58
  2. package/dist-client/pages/figure-library-page.js +189 -672
  3. package/dist-client/pages/figure-library-page.js.map +1 -1
  4. package/dist-client/tsconfig.tsbuildinfo +1 -1
  5. package/dist-client/viewparts/figure-card-meta.d.ts +19 -0
  6. package/dist-client/viewparts/figure-card-meta.js +122 -0
  7. package/dist-client/viewparts/figure-card-meta.js.map +1 -0
  8. package/dist-client/viewparts/figure-releases-popup.d.ts +34 -0
  9. package/dist-client/viewparts/figure-releases-popup.js +400 -0
  10. package/dist-client/viewparts/figure-releases-popup.js.map +1 -0
  11. package/dist-client/viewparts/release-pair.d.ts +9 -0
  12. package/dist-client/viewparts/release-pair.js +15 -0
  13. package/dist-client/viewparts/release-pair.js.map +1 -0
  14. package/dist-server/service/figure-library-release/figure-library-release.d.ts +5 -3
  15. package/dist-server/service/figure-library-release/figure-library-release.js +13 -3
  16. package/dist-server/service/figure-library-release/figure-library-release.js.map +1 -1
  17. package/dist-server/service/figure-library-resolver.d.ts +9 -9
  18. package/dist-server/service/figure-library-resolver.js +66 -69
  19. package/dist-server/service/figure-library-resolver.js.map +1 -1
  20. package/dist-server/service/figure-library-types.d.ts +17 -4
  21. package/dist-server/service/figure-library-types.js +63 -15
  22. package/dist-server/service/figure-library-types.js.map +1 -1
  23. package/dist-server/service/figure-type-map/figure-type-map-entry.d.ts +5 -4
  24. package/dist-server/service/figure-type-map/figure-type-map-entry.js +8 -14
  25. package/dist-server/service/figure-type-map/figure-type-map-entry.js.map +1 -1
  26. package/dist-server/service/index.d.ts +2 -3
  27. package/dist-server/service/index.js +2 -3
  28. package/dist-server/service/index.js.map +1 -1
  29. package/dist-server/service/library/blueprints.d.ts +3 -8
  30. package/dist-server/service/library/blueprints.js +5 -6
  31. package/dist-server/service/library/blueprints.js.map +1 -1
  32. package/dist-server/service/library/carriers.d.ts +8 -11
  33. package/dist-server/service/library/carriers.js +8 -14
  34. package/dist-server/service/library/carriers.js.map +1 -1
  35. package/dist-server/service/library/derived.d.ts +5 -3
  36. package/dist-server/service/library/derived.js +4 -3
  37. package/dist-server/service/library/derived.js.map +1 -1
  38. package/dist-server/service/library/figures.d.ts +46 -0
  39. package/dist-server/service/library/figures.js +91 -0
  40. package/dist-server/service/library/figures.js.map +1 -0
  41. package/dist-server/service/library/import.d.ts +1 -1
  42. package/dist-server/service/library/import.js +5 -3
  43. package/dist-server/service/library/import.js.map +1 -1
  44. package/dist-server/service/library/inspection.d.ts +1 -48
  45. package/dist-server/service/library/inspection.js +3 -80
  46. package/dist-server/service/library/inspection.js.map +1 -1
  47. package/dist-server/service/library/type-map.d.ts +10 -22
  48. package/dist-server/service/library/type-map.js +44 -108
  49. package/dist-server/service/library/type-map.js.map +1 -1
  50. package/dist-server/tsconfig.tsbuildinfo +1 -1
  51. package/package.json +11 -10
  52. package/translations/en.json +26 -47
  53. package/translations/es.json +26 -47
  54. package/translations/ja.json +26 -47
  55. package/translations/ko.json +26 -47
  56. package/translations/ms.json +26 -47
  57. package/translations/zh.json +26 -47
  58. package/dist-server/service/figure-type-map/figure-type-map.d.ts +0 -34
  59. package/dist-server/service/figure-type-map/figure-type-map.js +0 -120
  60. package/dist-server/service/figure-type-map/figure-type-map.js.map +0 -1
@@ -0,0 +1,15 @@
1
+ /** At most this many releases stand side by side in the compare. */
2
+ export const SIDE_BY_SIDE = 2;
3
+ /**
4
+ * The releases a compare opens on (releases newest first): the one in use and the latest; when they are the same
5
+ * release, or nothing is in use, the latest and the one before it.
6
+ */
7
+ export function defaultPair(releases, drawing) {
8
+ const latest = releases[0]?.id;
9
+ if (!latest)
10
+ return [];
11
+ const inUse = releases.some(release => release.id === drawing) ? drawing : undefined;
12
+ const pair = inUse && inUse !== latest ? [inUse, latest] : [latest, releases[1]?.id];
13
+ return pair.filter((id) => !!id).slice(0, SIDE_BY_SIDE);
14
+ }
15
+ //# sourceMappingURL=release-pair.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"release-pair.js","sourceRoot":"","sources":["../../client/viewparts/release-pair.ts"],"names":[],"mappings":"AAAA,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAA;AAE7B;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,QAAmC,EAAE,OAAe;IAC9E,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;IAC9B,IAAI,CAAC,MAAM;QAAE,OAAO,EAAE,CAAA;IACtB,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;IACpF,MAAM,IAAI,GAAG,KAAK,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACpF,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAA;AACvE,CAAC","sourcesContent":["/** At most this many releases stand side by side in the compare. */\nexport const SIDE_BY_SIDE = 2\n\n/**\n * The releases a compare opens on (releases newest first): the one in use and the latest; when they are the same\n * release, or nothing is in use, the latest and the one before it.\n */\nexport function defaultPair(releases: readonly { id: string }[], drawing: string): string[] {\n const latest = releases[0]?.id\n if (!latest) return []\n const inUse = releases.some(release => release.id === drawing) ? drawing : undefined\n const pair = inUse && inUse !== latest ? [inUse, latest] : [latest, releases[1]?.id]\n return pair.filter((id): id is string => !!id).slice(0, SIDE_BY_SIDE)\n}\n"]}
@@ -11,9 +11,9 @@ export interface FigureLibraryDependency {
11
11
  * A released figure this board server imported (ADR-0114 결정 3).
12
12
  *
13
13
  * The release data is immutable: the server that authored it never changes a release, so a row is added once and never
14
- * rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` · `carrierType` · `carrierDimensions`
15
- * are derived, recomputed when this server's kernel is another version than the one that checked them. There is no delete
16
- * path.
14
+ * rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` · `capabilities` · `carrierType` ·
15
+ * `carrierDimensions` are derived, recomputed when this server's kernel is another version than the one that checked them.
16
+ * Kept as columns so a list filters on them without reading every source. There is no delete path.
17
17
  */
18
18
  export declare class FigureLibraryRelease {
19
19
  readonly id?: string;
@@ -38,6 +38,7 @@ export declare class FigureLibraryRelease {
38
38
  checkedKernel?: string;
39
39
  width?: number;
40
40
  depth?: number;
41
+ capabilities?: string[];
41
42
  carrierType?: string;
42
43
  carrierDimensions?: {
43
44
  width: number;
@@ -45,6 +46,7 @@ export declare class FigureLibraryRelease {
45
46
  height: number;
46
47
  };
47
48
  dependencies?: FigureLibraryDependency[];
49
+ comment?: string;
48
50
  deprecated: boolean;
49
51
  supersededBy?: string;
50
52
  sourceUrl?: string;
@@ -11,9 +11,9 @@ const shell_1 = require("@things-factory/shell");
11
11
  * A released figure this board server imported (ADR-0114 결정 3).
12
12
  *
13
13
  * The release data is immutable: the server that authored it never changes a release, so a row is added once and never
14
- * rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` · `carrierType` · `carrierDimensions`
15
- * are derived, recomputed when this server's kernel is another version than the one that checked them. There is no delete
16
- * path.
14
+ * rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` · `capabilities` · `carrierType` ·
15
+ * `carrierDimensions` are derived, recomputed when this server's kernel is another version than the one that checked them.
16
+ * Kept as columns so a list filters on them without reading every source. There is no delete path.
17
17
  */
18
18
  let FigureLibraryRelease = class FigureLibraryRelease {
19
19
  };
@@ -127,6 +127,11 @@ tslib_1.__decorate([
127
127
  (0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Derived: authored depth (size.z) in mm. Null when unread.' }),
128
128
  tslib_1.__metadata("design:type", Number)
129
129
  ], FigureLibraryRelease.prototype, "depth", void 0);
130
+ tslib_1.__decorate([
131
+ (0, typeorm_1.Column)('simple-json', { nullable: true, default: null }),
132
+ (0, type_graphql_1.Field)(type => [String], { nullable: true, description: 'Derived: the roles of the places the source declares (seat, grip), [] for none. Null when unread.' }),
133
+ tslib_1.__metadata("design:type", Array)
134
+ ], FigureLibraryRelease.prototype, "capabilities", void 0);
130
135
  tslib_1.__decorate([
131
136
  (0, typeorm_1.Column)({ nullable: true }),
132
137
  (0, type_graphql_1.Field)({ nullable: true, description: 'Derived: the CARRIERTYPE code a carrier figure declares, trimmed and upper case. Null when none.' }),
@@ -142,6 +147,11 @@ tslib_1.__decorate([
142
147
  (0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'Files the release depends on: [{ hash, role, size, contentType }].' }),
143
148
  tslib_1.__metadata("design:type", Array)
144
149
  ], FigureLibraryRelease.prototype, "dependencies", void 0);
150
+ tslib_1.__decorate([
151
+ (0, typeorm_1.Column)({ type: 'text', nullable: true }),
152
+ (0, type_graphql_1.Field)({ nullable: true, description: 'The note the author left when releasing this version.' }),
153
+ tslib_1.__metadata("design:type", String)
154
+ ], FigureLibraryRelease.prototype, "comment", void 0);
145
155
  tslib_1.__decorate([
146
156
  (0, typeorm_1.Column)({ default: false }),
147
157
  (0, type_graphql_1.Field)({ description: 'Retired at the authoring server.' }),
@@ -1 +1 @@
1
- {"version":3,"file":"figure-library-release.js","sourceRoot":"","sources":["../../../server/service/figure-library-release/figure-library-release.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAgE;AAChE,qDAA6C;AAE7C,yDAAgD;AAChD,iDAA8D;AAU9D;;;;;;;GAOG;AAQI,IAAM,oBAAoB,GAA1B,M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AAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;sCAC5E,gBAAI;qDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;uDAC7C;+BApJP,oBAAoB;IAPhC,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,6BAA6B,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;QACtG,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,eAAK,EAAC,6BAA6B,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1H,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,mFAAmF,EAAE,CAAC;GACpG,oBAAoB,CAqJhC","sourcesContent":["import {\n Column,\n CreateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, longTextColumn } from '@things-factory/shell'\n\n/** A file a release depends on, as its package listed it. */\nexport interface FigureLibraryDependency {\n hash: string\n role: string\n size: number\n contentType: string\n}\n\n/**\n * A released figure this board server imported (ADR-0114 결정 3).\n *\n * The release data is immutable: the server that authored it never changes a release, so a row is added once and never\n * rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` · `carrierType` · `carrierDimensions`\n * are derived, recomputed when this server's kernel is another version than the one that checked them. There is no delete\n * path.\n */\n@Entity()\n@Index('ix_figure_library_release_1', (release: FigureLibraryRelease) => [release.domain, release.ref], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@Index('ix_figure_library_release_2', (release: FigureLibraryRelease) => [release.domain, release.namespace, release.type])\n@ObjectType({ description: 'A released figure imported into this board server, one row per release reference.' })\nexport class FigureLibraryRelease {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier.' })\n readonly id?: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain that imported the release.' })\n domain?: Domain\n\n @RelationId((release: FigureLibraryRelease) => release.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'Display name of the figure at this release.' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Description of the figure at this release.' })\n description?: string\n\n @Column()\n @Field({ description: 'Release reference {namespace}/{type}@{version}.' })\n ref: string\n\n @Column()\n @Field({ description: 'Namespace of the full name.' })\n namespace: string\n\n @Column()\n @Field({ description: 'Type of the full name.' })\n type: string\n\n @Column()\n @Field(type => Int, { description: 'Release version.' })\n version: number\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Display names by language.' })\n names?: Record<string, string>\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Category of the figure at this release.' })\n category?: string\n\n @Column({ ...longTextColumn() })\n @Field({ description: 'The released source, as the authoring server released it.' })\n source: string\n\n @Column({ length: 64 })\n @Field({ description: 'SHA-256 of the source. Same reference and hash is the same release.' })\n contentHash: string\n\n @Column()\n @Field({ description: 'The format the source declares (figure-asset-1).' })\n assetFormat: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Kernel version that released it on the authoring server.' })\n kernelVersion?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'What the release measured, as JSON text.' })\n metrics?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'Top view of the release, as JSON text.' })\n topView?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'Contract changes against its previous release, as JSON text.' })\n changes?: string\n\n @Column({ default: false })\n @Field({ description: 'Derived: whether this server kernel reads the source.' })\n formatSupported: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Derived: kernel version that checked the source here.' })\n checkedKernel?: string\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Derived: authored width (size.x) in mm. Null when unread.' })\n width?: number\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Derived: authored depth (size.z) in mm. Null when unread.' })\n depth?: number\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Derived: the CARRIERTYPE code a carrier figure declares, trimmed and upper case. Null when none.' })\n carrierType?: string\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Derived: the declared physical size of a carrier figure in mm, { width, length, height }.' })\n carrierDimensions?: { width: number; length: number; height: number }\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Files the release depends on: [{ hash, role, size, contentType }].' })\n dependencies?: FigureLibraryDependency[]\n\n @Column({ default: false })\n @Field({ description: 'Retired at the authoring server.' })\n deprecated: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Full name to use instead of a retired figure.' })\n supersededBy?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Address of the figure server the package came from.' })\n sourceUrl?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Domain of the figure server the package came from.' })\n sourceDomain?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'File name of the package it was imported from.' })\n packageName?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When the authoring server released it.' })\n releasedAt?: Date\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Creation timestamp (when it was imported).' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Last update timestamp.' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'Soft-delete timestamp. Releases are not deleted.' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who imported it.' })\n creator?: User\n\n @RelationId((release: FigureLibraryRelease) => release.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who last updated it.' })\n updater?: User\n\n @RelationId((release: FigureLibraryRelease) => release.updater)\n updaterId?: string\n}\n"]}
1
+ {"version":3,"file":"figure-library-release.js","sourceRoot":"","sources":["../../../server/service/figure-library-release/figure-library-release.ts"],"names":[],"mappings":";;;;AAAA,qCAUgB;AAChB,+CAAgE;AAChE,qDAA6C;AAE7C,yDAAgD;AAChD,iDAA8D;AAU9D;;;;;;;GAOG;AAQI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CA6JhC,CAAA;AA7JY,oDAAoB;AAGtB;IAFR,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,EAAE,EAAE,WAAW,EAAE,oBAAoB,EAAE,CAAC;;gDACrC;AAIpB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IACzB,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,uCAAuC,EAAE,CAAC;sCACvF,cAAM;oDAAA;AAGf;IADC,IAAA,oBAAU,EAAC,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;;sDAC7C;AAIjB;IAFC,IAAA,gBAAM,GAAE;IACR,IAAA,oBAAK,EAAC,EAAE,WAAW,EAAE,6CAA6C,EAAE,CAAC;;kDAC1D;AAIZ;IAFC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,E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C,IAAA,gBAAM,GAAE;IACR,IAAA,eAAK,EAAC,6BAA6B,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE;QACtG,MAAM,EAAE,IAAI;QACZ,KAAK,EAAE,sBAAsB;KAC9B,CAAC;IACD,IAAA,eAAK,EAAC,6BAA6B,EAAE,CAAC,OAA6B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1H,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,mFAAmF,EAAE,CAAC;GACpG,oBAAoB,CA6JhC","sourcesContent":["import {\n Column,\n CreateDateColumn,\n DeleteDateColumn,\n Entity,\n Index,\n ManyToOne,\n PrimaryGeneratedColumn,\n RelationId,\n UpdateDateColumn\n} from 'typeorm'\nimport { Field, Float, ID, Int, ObjectType } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\n\nimport { User } from '@things-factory/auth-base'\nimport { Domain, longTextColumn } from '@things-factory/shell'\n\n/** A file a release depends on, as its package listed it. */\nexport interface FigureLibraryDependency {\n hash: string\n role: string\n size: number\n contentType: string\n}\n\n/**\n * A released figure this board server imported (ADR-0114 결정 3).\n *\n * The release data is immutable: the server that authored it never changes a release, so a row is added once and never\n * rewritten from a package. `formatSupported` · `checkedKernel` · `width` · `depth` · `capabilities` · `carrierType` ·\n * `carrierDimensions` are derived, recomputed when this server's kernel is another version than the one that checked them.\n * Kept as columns so a list filters on them without reading every source. There is no delete path.\n */\n@Entity()\n@Index('ix_figure_library_release_1', (release: FigureLibraryRelease) => [release.domain, release.ref], {\n unique: true,\n where: '\"deleted_at\" IS NULL'\n})\n@Index('ix_figure_library_release_2', (release: FigureLibraryRelease) => [release.domain, release.namespace, release.type])\n@ObjectType({ description: 'A released figure imported into this board server, one row per release reference.' })\nexport class FigureLibraryRelease {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID, { description: 'Unique identifier.' })\n readonly id?: string\n\n @ManyToOne(type => Domain)\n @Field(type => Domain, { nullable: true, description: 'The domain that imported the release.' })\n domain?: Domain\n\n @RelationId((release: FigureLibraryRelease) => release.domain)\n domainId?: string\n\n @Column()\n @Field({ description: 'Display name of the figure at this release.' })\n name: string\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'Description of the figure at this release.' })\n description?: string\n\n @Column()\n @Field({ description: 'Release reference {namespace}/{type}@{version}.' })\n ref: string\n\n @Column()\n @Field({ description: 'Namespace of the full name.' })\n namespace: string\n\n @Column()\n @Field({ description: 'Type of the full name.' })\n type: string\n\n @Column()\n @Field(type => Int, { description: 'Release version.' })\n version: number\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Display names by language.' })\n names?: Record<string, string>\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Category of the figure at this release.' })\n category?: string\n\n @Column({ ...longTextColumn() })\n @Field({ description: 'The released source, as the authoring server released it.' })\n source: string\n\n @Column({ length: 64 })\n @Field({ description: 'SHA-256 of the source. Same reference and hash is the same release.' })\n contentHash: string\n\n @Column()\n @Field({ description: 'The format the source declares (figure-asset-1).' })\n assetFormat: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Kernel version that released it on the authoring server.' })\n kernelVersion?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'What the release measured, as JSON text.' })\n metrics?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'Top view of the release, as JSON text.' })\n topView?: string\n\n @Column({ nullable: true, ...longTextColumn() })\n @Field({ nullable: true, description: 'Contract changes against its previous release, as JSON text.' })\n changes?: string\n\n @Column({ default: false })\n @Field({ description: 'Derived: whether this server kernel reads the source.' })\n formatSupported: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Derived: kernel version that checked the source here.' })\n checkedKernel?: string\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Derived: authored width (size.x) in mm. Null when unread.' })\n width?: number\n\n @Column({ type: 'float', nullable: true })\n @Field(type => Float, { nullable: true, description: 'Derived: authored depth (size.z) in mm. Null when unread.' })\n depth?: number\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => [String], { nullable: true, description: 'Derived: the roles of the places the source declares (seat, grip), [] for none. Null when unread.' })\n capabilities?: string[]\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Derived: the CARRIERTYPE code a carrier figure declares, trimmed and upper case. Null when none.' })\n carrierType?: string\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Derived: the declared physical size of a carrier figure in mm, { width, length, height }.' })\n carrierDimensions?: { width: number; length: number; height: number }\n\n @Column('simple-json', { nullable: true, default: null })\n @Field(type => GraphQLJSON, { nullable: true, description: 'Files the release depends on: [{ hash, role, size, contentType }].' })\n dependencies?: FigureLibraryDependency[]\n\n @Column({ type: 'text', nullable: true })\n @Field({ nullable: true, description: 'The note the author left when releasing this version.' })\n comment?: string\n\n @Column({ default: false })\n @Field({ description: 'Retired at the authoring server.' })\n deprecated: boolean\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Full name to use instead of a retired figure.' })\n supersededBy?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Address of the figure server the package came from.' })\n sourceUrl?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'Domain of the figure server the package came from.' })\n sourceDomain?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'File name of the package it was imported from.' })\n packageName?: string\n\n @Column({ nullable: true })\n @Field({ nullable: true, description: 'When the authoring server released it.' })\n releasedAt?: Date\n\n @CreateDateColumn()\n @Field({ nullable: true, description: 'Creation timestamp (when it was imported).' })\n createdAt?: Date\n\n @UpdateDateColumn()\n @Field({ nullable: true, description: 'Last update timestamp.' })\n updatedAt?: Date\n\n @DeleteDateColumn()\n @Field({ nullable: true, description: 'Soft-delete timestamp. Releases are not deleted.' })\n deletedAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who imported it.' })\n creator?: User\n\n @RelationId((release: FigureLibraryRelease) => release.creator)\n creatorId?: string\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true, description: 'The user who last updated it.' })\n updater?: User\n\n @RelationId((release: FigureLibraryRelease) => release.updater)\n updaterId?: string\n}\n"]}
@@ -1,21 +1,21 @@
1
1
  import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
2
2
  import { ListParam } from '@things-factory/shell';
3
- import { FigureTypeMap, FigureTypeMapState } from './figure-type-map/figure-type-map';
3
+ import { FigureLibraryRelease } from './figure-library-release/figure-library-release';
4
4
  import { FigureTypeMapEntry } from './figure-type-map/figure-type-map-entry';
5
- import { FigureImportResult, FigureLibraryReleaseList, FigureTypeMapLineInput } from './figure-library-types';
5
+ import { FigureImportResult, FigureLibraryFacets, FigureLibraryFigureList, FigureLibraryReleaseList } from './figure-library-types';
6
6
  /**
7
7
  * The library and the type map of a board server (ADR-0114). Reading is `figure-library` query; changing is its
8
8
  * mutation. Boards ask `figureBlueprints` under `figure-published`, the door every figure consumer asks through.
9
9
  */
10
10
  export declare class FigureLibraryResolver {
11
11
  figureLibraryReleases(params: ListParam, context: ResolverContext): Promise<FigureLibraryReleaseList>;
12
- figureTypeMaps(context: ResolverContext): Promise<FigureTypeMap[]>;
13
- figureTypeMapEntries(version: number, context: ResolverContext): Promise<FigureTypeMapEntry[]>;
14
- figureTypeMapCheck(context: ResolverContext): Promise<any>;
12
+ figureLibraryFigures(params: ListParam, context: ResolverContext): Promise<FigureLibraryFigureList>;
13
+ figureLibraryFacets(context: ResolverContext): Promise<FigureLibraryFacets>;
14
+ figureLibraryReleasesOf(name: string, context: ResolverContext): Promise<FigureLibraryRelease[]>;
15
+ figureTypeMap(context: ResolverContext): Promise<FigureTypeMapEntry[]>;
15
16
  figureBoardRequirements(boardId: string, context: ResolverContext): Promise<any>;
16
- figureBlueprints(types: string[], context: ResolverContext, map?: FigureTypeMapState): Promise<any>;
17
- figureCarrierTypes(carrierTypes: string[], context: ResolverContext, map?: FigureTypeMapState): Promise<any>;
17
+ figureBlueprints(types: string[], context: ResolverContext): Promise<any>;
18
+ figureCarrierTypes(carrierTypes: string[], context: ResolverContext): Promise<any>;
18
19
  importFigurePackage(file: FileUpload, context: ResolverContext): Promise<FigureImportResult>;
19
- saveFigureTypeMapCandidate(lines: FigureTypeMapLineInput[], context: ResolverContext, description?: string): Promise<FigureTypeMap>;
20
- activateFigureTypeMap(version: number, context: ResolverContext): Promise<FigureTypeMap>;
20
+ chooseFigureRelease(name: string, releaseId: string, context: ResolverContext): Promise<FigureTypeMapEntry>;
21
21
  }
@@ -5,12 +5,11 @@ const tslib_1 = require("tslib");
5
5
  const type_graphql_1 = require("type-graphql");
6
6
  const graphql_scalars_1 = require("graphql-scalars");
7
7
  const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
8
- const auth_base_1 = require("@things-factory/auth-base");
9
8
  const shell_1 = require("@things-factory/shell");
10
9
  const figure_library_release_1 = require("./figure-library-release/figure-library-release");
11
- const figure_type_map_1 = require("./figure-type-map/figure-type-map");
12
10
  const figure_type_map_entry_1 = require("./figure-type-map/figure-type-map-entry");
13
11
  const figure_library_types_1 = require("./figure-library-types");
12
+ const figures_1 = require("./library/figures");
14
13
  const blueprints_1 = require("./library/blueprints");
15
14
  const carriers_1 = require("./library/carriers");
16
15
  const import_1 = require("./library/import");
@@ -25,16 +24,6 @@ function plainTextOf(refusal, context) {
25
24
  ? context.t((0, shell_1.refusalKey)(refusal.code), { ...refusal.params, defaultValue: refusal.message, interpolation: { escapeValue: false } })
26
25
  : refusal.message;
27
26
  }
28
- /** The map a reader asked: the active one, or the candidate, which only those who may change it preview. */
29
- async function mapAsked(map, context) {
30
- if (map !== figure_type_map_1.FigureTypeMapState.CANDIDATE)
31
- return figure_type_map_1.FigureTypeMapState.ACTIVE;
32
- const { domain, user, unsafeIP, prohibitedPrivileges } = context.state;
33
- const allowed = await (0, auth_base_1.checkPermission)({ category: 'figure-library', privilege: 'mutation', owner: true }, user, domain, unsafeIP, prohibitedPrivileges);
34
- if (!allowed)
35
- throw new shell_1.Refusal('figure-type-map-preview-denied', {}, 'previewing the candidate type map needs the right to change it.');
36
- return figure_type_map_1.FigureTypeMapState.CANDIDATE;
37
- }
38
27
  /** The most bytes one package upload may carry. */
39
28
  const PACKAGE_MAX_BYTES = 64 * 1024 * 1024;
40
29
  async function bytesOf(file) {
@@ -68,32 +57,48 @@ let FigureLibraryResolver = class FigureLibraryResolver {
68
57
  await (0, inspection_1.freshen)(manager, item);
69
58
  return { items, total };
70
59
  }
71
- async figureTypeMaps(context) {
60
+ async figureLibraryFigures(params, context) {
72
61
  const { domain } = context.state;
73
- return await (0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).find({ where: { domain: { id: domain.id } }, order: { version: 'DESC' } });
62
+ const value = (name) => {
63
+ const found = params.filters?.find(filter => filter.name === name)?.value;
64
+ return Array.isArray(found) ? found[0] : found ?? undefined;
65
+ };
66
+ const manager = (0, shell_1.getRepository)(figure_type_map_entry_1.FigureTypeMapEntry).manager;
67
+ const result = await (0, figures_1.figuresOf)(manager, domain, {
68
+ category: value('category'),
69
+ capability: value('capability'),
70
+ search: value('name'),
71
+ page: params.pagination?.page,
72
+ limit: params.pagination?.limit
73
+ });
74
+ for (const item of result.items) {
75
+ if (item.release)
76
+ await (0, inspection_1.freshen)(manager, item.release);
77
+ await (0, inspection_1.freshen)(manager, item.latest);
78
+ }
79
+ return result;
74
80
  }
75
- async figureTypeMapEntries(version, context) {
76
- const { domain } = context.state;
77
- const map = await (0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).findOne({ where: { domain: { id: domain.id }, version } });
78
- return map ? await (0, type_map_1.entriesOf)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, map) : [];
81
+ async figureLibraryFacets(context) {
82
+ return await (0, figures_1.figureFacetsOf)((0, shell_1.getRepository)(figure_type_map_entry_1.FigureTypeMapEntry).manager, context.state.domain);
83
+ }
84
+ async figureLibraryReleasesOf(name, context) {
85
+ return await (0, figures_1.releasesOfName)((0, shell_1.getRepository)(figure_library_release_1.FigureLibraryRelease).manager, context.state.domain, name);
79
86
  }
80
- async figureTypeMapCheck(context) {
87
+ async figureTypeMap(context) {
81
88
  const { domain } = context.state;
82
- return await (0, inspection_1.typeMapCheck)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain);
89
+ return await (0, type_map_1.linesOf)((0, shell_1.getRepository)(figure_type_map_entry_1.FigureTypeMapEntry).manager, domain);
83
90
  }
84
91
  async figureBoardRequirements(boardId, context) {
85
92
  const { domain } = context.state;
86
- return await (0, inspection_1.boardRequirements)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain, boardId);
93
+ return await (0, inspection_1.boardRequirements)((0, shell_1.getRepository)(figure_type_map_entry_1.FigureTypeMapEntry).manager, domain, boardId);
87
94
  }
88
- async figureBlueprints(types, context, map) {
95
+ async figureBlueprints(types, context) {
89
96
  const { domain } = context.state;
90
- const state = await mapAsked(map, context);
91
- return await (0, blueprints_1.blueprintsOf)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain, types, state, refusal => plainTextOf(refusal, context));
97
+ return await (0, blueprints_1.blueprintsOf)((0, shell_1.getRepository)(figure_type_map_entry_1.FigureTypeMapEntry).manager, domain, types, refusal => plainTextOf(refusal, context));
92
98
  }
93
- async figureCarrierTypes(carrierTypes, context, map) {
99
+ async figureCarrierTypes(carrierTypes, context) {
94
100
  const { domain } = context.state;
95
- const state = await mapAsked(map, context);
96
- return await (0, carriers_1.carrierTypesOf)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain, carrierTypes, state, refusal => plainTextOf(refusal, context));
101
+ return await (0, carriers_1.carrierTypesOf)((0, shell_1.getRepository)(figure_type_map_entry_1.FigureTypeMapEntry).manager, domain, carrierTypes, refusal => plainTextOf(refusal, context));
97
102
  }
98
103
  async importFigurePackage(file, context) {
99
104
  const { domain, user, tx } = context.state;
@@ -101,13 +106,9 @@ let FigureLibraryResolver = class FigureLibraryResolver {
101
106
  (0, import_1.assertPackageName)(upload.filename);
102
107
  return await (0, import_1.importFigurePackage)(tx, domain, user, await bytesOf(upload), upload.filename);
103
108
  }
104
- async saveFigureTypeMapCandidate(lines, context, description) {
109
+ async chooseFigureRelease(name, releaseId, context) {
105
110
  const { domain, user, tx } = context.state;
106
- return await (0, type_map_1.saveCandidate)(tx, domain, user, lines, description);
107
- }
108
- async activateFigureTypeMap(version, context) {
109
- const { domain, user, tx } = context.state;
110
- return await (0, type_map_1.activate)(tx, domain, user, version);
111
+ return await (0, type_map_1.chooseRelease)(tx, domain, user, name, releaseId);
111
112
  }
112
113
  };
113
114
  exports.FigureLibraryResolver = FigureLibraryResolver;
@@ -122,35 +123,43 @@ tslib_1.__decorate([
122
123
  ], FigureLibraryResolver.prototype, "figureLibraryReleases", null);
123
124
  tslib_1.__decorate([
124
125
  (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
125
- (0, type_graphql_1.Query)(returns => [figure_type_map_1.FigureTypeMap], { description: 'The type map releases of this domain, newest first.' }),
126
+ (0, type_graphql_1.Query)(returns => figure_library_types_1.FigureLibraryFigureList, {
127
+ description: 'Imported figures, one per full name, with the release each draws with. Filters: category, capability ("-" for none), name (search).'
128
+ }),
129
+ tslib_1.__param(0, (0, type_graphql_1.Args)()),
130
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
131
+ tslib_1.__metadata("design:type", Function),
132
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
133
+ tslib_1.__metadata("design:returntype", Promise)
134
+ ], FigureLibraryResolver.prototype, "figureLibraryFigures", null);
135
+ tslib_1.__decorate([
136
+ (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
137
+ (0, type_graphql_1.Query)(returns => figure_library_types_1.FigureLibraryFacets, { description: 'The categories and capabilities the figure filters offer.' }),
126
138
  tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
127
139
  tslib_1.__metadata("design:type", Function),
128
140
  tslib_1.__metadata("design:paramtypes", [Object]),
129
141
  tslib_1.__metadata("design:returntype", Promise)
130
- ], FigureLibraryResolver.prototype, "figureTypeMaps", null);
142
+ ], FigureLibraryResolver.prototype, "figureLibraryFacets", null);
131
143
  tslib_1.__decorate([
132
144
  (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
133
- (0, type_graphql_1.Query)(returns => [figure_type_map_entry_1.FigureTypeMapEntry], { description: 'The lines of one type map release, with the release each draws with.' }),
134
- tslib_1.__param(0, (0, type_graphql_1.Arg)('version', type => type_graphql_1.Int)),
145
+ (0, type_graphql_1.Query)(returns => [figure_library_release_1.FigureLibraryRelease], { description: 'Every imported release of one full figure name, newest first.' }),
146
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('name')),
135
147
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
136
148
  tslib_1.__metadata("design:type", Function),
137
- tslib_1.__metadata("design:paramtypes", [Number, Object]),
149
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
138
150
  tslib_1.__metadata("design:returntype", Promise)
139
- ], FigureLibraryResolver.prototype, "figureTypeMapEntries", null);
151
+ ], FigureLibraryResolver.prototype, "figureLibraryReleasesOf", null);
140
152
  tslib_1.__decorate([
141
- (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
142
- (0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, {
143
- nullable: true,
144
- description: 'The check before activation: the candidate against the active map and every board of the domain. Null without a candidate.'
145
- }),
153
+ (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
154
+ (0, type_graphql_1.Query)(returns => [figure_type_map_entry_1.FigureTypeMapEntry], { description: 'The type map of this domain: one line per full figure name, with the release it draws with.' }),
146
155
  tslib_1.__param(0, (0, type_graphql_1.Ctx)()),
147
156
  tslib_1.__metadata("design:type", Function),
148
157
  tslib_1.__metadata("design:paramtypes", [Object]),
149
158
  tslib_1.__metadata("design:returntype", Promise)
150
- ], FigureLibraryResolver.prototype, "figureTypeMapCheck", null);
159
+ ], FigureLibraryResolver.prototype, "figureTypeMap", null);
151
160
  tslib_1.__decorate([
152
161
  (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "query", domainOwnerGranted: true)'),
153
- (0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'What one board needs from the active type map: each figure, its status and node count.' }),
162
+ (0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'What one board needs from the type map: each figure, its status and node count.' }),
154
163
  tslib_1.__param(0, (0, type_graphql_1.Arg)('boardId')),
155
164
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
156
165
  tslib_1.__metadata("design:type", Function),
@@ -160,31 +169,29 @@ tslib_1.__decorate([
160
169
  tslib_1.__decorate([
161
170
  (0, type_graphql_1.Directive)('@privilege(category: "figure-published", privilege: "query", domainOwnerGranted: true)'),
162
171
  (0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, {
163
- description: 'Figures a board asks for together by full name {namespace}/{type}, answered from one type map release: { release: { version, revision }, items: [{ type, ref, asset }], refused: [{ type, code, message }] }.'
172
+ description: 'Figures a board asks for together by full name {namespace}/{type}, answered from the type map: { items: [{ type, ref, asset }], refused: [{ type, code, message }] }.'
164
173
  }),
165
174
  tslib_1.__param(0, (0, type_graphql_1.Arg)('types', type => [String], { description: 'Full figure names {namespace}/{type}. At most 500.' })),
166
175
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
167
- tslib_1.__param(2, (0, type_graphql_1.Arg)('map', type => figure_type_map_1.FigureTypeMapState, { nullable: true, description: 'ACTIVE (default) or CANDIDATE for a preview.' })),
168
176
  tslib_1.__metadata("design:type", Function),
169
- tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
177
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
170
178
  tslib_1.__metadata("design:returntype", Promise)
171
179
  ], FigureLibraryResolver.prototype, "figureBlueprints", null);
172
180
  tslib_1.__decorate([
173
181
  (0, type_graphql_1.Directive)('@privilege(category: "figure-published", privilege: "query", domainOwnerGranted: true)'),
174
182
  (0, type_graphql_1.Query)(returns => graphql_scalars_1.GraphQLJSON, {
175
- description: 'Carrier types live data names by CARRIERTYPE code, answered from one type map release (ADR-0123): { release: { version, revision }, items: [{ carrierType, name, ref, dimensions: { width, length, height } }], refused: [{ carrierType, code, message, refs? }] }.'
183
+ description: 'Carrier types live data names by CARRIERTYPE code, answered from the type map (ADR-0123): { items: [{ carrierType, name, ref, dimensions: { width, length, height } }], refused: [{ carrierType, code, message, refs? }] }.'
176
184
  }),
177
185
  tslib_1.__param(0, (0, type_graphql_1.Arg)('carrierTypes', type => [String], { description: 'CARRIERTYPE codes, compared trimmed and upper case. At most 500.' })),
178
186
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
179
- tslib_1.__param(2, (0, type_graphql_1.Arg)('map', type => figure_type_map_1.FigureTypeMapState, { nullable: true, description: 'ACTIVE (default) or CANDIDATE for a preview.' })),
180
187
  tslib_1.__metadata("design:type", Function),
181
- tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
188
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
182
189
  tslib_1.__metadata("design:returntype", Promise)
183
190
  ], FigureLibraryResolver.prototype, "figureCarrierTypes", null);
184
191
  tslib_1.__decorate([
185
192
  (0, type_graphql_1.Directive)('@transaction'),
186
193
  (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
187
- (0, type_graphql_1.Mutation)(returns => figure_library_types_1.FigureImportResult, { description: 'Imports a figure package into this domain library and its candidate type map.' }),
194
+ (0, type_graphql_1.Mutation)(returns => figure_library_types_1.FigureImportResult, { description: 'Imports a figure package into this domain library. A release newer than the one its name draws with becomes the one it draws with.' }),
188
195
  tslib_1.__param(0, (0, type_graphql_1.Arg)('file', () => GraphQLUpload_js_1.default)),
189
196
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
190
197
  tslib_1.__metadata("design:type", Function),
@@ -194,24 +201,14 @@ tslib_1.__decorate([
194
201
  tslib_1.__decorate([
195
202
  (0, type_graphql_1.Directive)('@transaction'),
196
203
  (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
197
- (0, type_graphql_1.Mutation)(returns => figure_type_map_1.FigureTypeMap, { description: 'Replaces the lines of the candidate type map. Each save raises its revision.' }),
198
- tslib_1.__param(0, (0, type_graphql_1.Arg)('lines', type => [figure_library_types_1.FigureTypeMapLineInput])),
199
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
200
- tslib_1.__param(2, (0, type_graphql_1.Arg)('description', { nullable: true })),
201
- tslib_1.__metadata("design:type", Function),
202
- tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
203
- tslib_1.__metadata("design:returntype", Promise)
204
- ], FigureLibraryResolver.prototype, "saveFigureTypeMapCandidate", null);
205
- tslib_1.__decorate([
206
- (0, type_graphql_1.Directive)('@transaction'),
207
- (0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
208
- (0, type_graphql_1.Mutation)(returns => figure_type_map_1.FigureTypeMap, { description: 'Activates a type map release: the candidate, or an archived one to roll back.' }),
209
- tslib_1.__param(0, (0, type_graphql_1.Arg)('version', type => type_graphql_1.Int)),
210
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
204
+ (0, type_graphql_1.Mutation)(returns => figure_type_map_entry_1.FigureTypeMapEntry, { description: 'Chooses the imported release a full figure name draws with.' }),
205
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('name', { description: 'Full figure name {namespace}/{type}.' })),
206
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('releaseId', { description: 'Id of an imported release of that name.' })),
207
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
211
208
  tslib_1.__metadata("design:type", Function),
212
- tslib_1.__metadata("design:paramtypes", [Number, Object]),
209
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
213
210
  tslib_1.__metadata("design:returntype", Promise)
214
- ], FigureLibraryResolver.prototype, "activateFigureTypeMap", null);
211
+ ], FigureLibraryResolver.prototype, "chooseFigureRelease", null);
215
212
  exports.FigureLibraryResolver = FigureLibraryResolver = tslib_1.__decorate([
216
213
  (0, type_graphql_1.Resolver)(),
217
214
  (0, type_graphql_1.UseMiddleware)(shell_1.SpeakRefusals)
@@ -1 +1 @@
1
- {"version":3,"file":"figure-library-resolver.js","sourceRoot":"","sources":["../../server/service/figure-library-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAAuG;AACvG,qDAA6C;AAE7C,+FAA2D;AAE3D,yDAA2D;AAC3D,iDAAmI;AAEnI,4FAAsF;AACtF,uEAAqF;AACrF,mFAA4E;AAC5E,iEAA6G;AAC7G,qDAAmD;AACnD,iDAAmD;AACnD,6CAAyE;AACzE,qDAA+E;AAC/E,iDAAuE;AAEvE;;;GAGG;AACH,SAAS,WAAW,CAAC,OAAgB,EAAE,OAAY;IACjD,OAAO,OAAO,CAAC,CAAC;QACd,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,kBAAU,EAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,aAAa,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,EAAE,CAAC;QAClI,CAAC,CAAC,OAAO,CAAC,OAAO,CAAA;AACrB,CAAC;AA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C,EAAE,CAAC,yCAAkB,EAAE,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;IAC/G,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAA;IAAoB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAKnF;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,yFAAyF,CAAC;IACpG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,+BAAa,EAAE,EAAE,WAAW,EAAE,8EAA8E,EAAE,CAAC;IAEjI,mBAAA,IAAA,kBAAG,EAAC,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,6CAAsB,CAAC,CAAC,CAAA;IAC9C,mBAAA,IAAA,kBAAG,GAAE,CAAA;IACL,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;;;;uEAIxC;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,yFAAyF,CAAC;IACpG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,+BAAa,EAAE,EAAE,WAAW,EAAE,+EAA+E,EAAE,CAAC;IACxG,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,kBAAG,CAAC,CAAA;IAAmB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;kEAG/E;gCA9GU,qBAAqB;IAFjC,IAAA,uBAAQ,GAAE;IACV,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,qBAAqB,CA+GjC","sourcesContent":["import { Arg, Args, Ctx, Directive, Int, Mutation, Query, Resolver, UseMiddleware } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\nimport type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\n\nimport { checkPermission } from '@things-factory/auth-base'\nimport { getQueryBuilderFromListParams, getRepository, ListParam, Refusal, refusalKey, SpeakRefusals } from '@things-factory/shell'\n\nimport { FigureLibraryRelease } from './figure-library-release/figure-library-release'\nimport { FigureTypeMap, FigureTypeMapState } from './figure-type-map/figure-type-map'\nimport { FigureTypeMapEntry } from './figure-type-map/figure-type-map-entry'\nimport { FigureImportResult, FigureLibraryReleaseList, FigureTypeMapLineInput } from './figure-library-types'\nimport { blueprintsOf } from './library/blueprints'\nimport { carrierTypesOf } from './library/carriers'\nimport { assertPackageName, importFigurePackage } from './library/import'\nimport { boardRequirements, freshen, typeMapCheck } from './library/inspection'\nimport { activate, entriesOf, saveCandidate } from './library/type-map'\n\n/**\n * A refusal in the asker's language as plain text: a board draws it on a canvas, not into HTML, so the values in it\n * (a name with `/`) are not escaped.\n */\nfunction plainTextOf(refusal: Refusal, context: any): string {\n return context.t\n ? context.t(refusalKey(refusal.code), { ...refusal.params, defaultValue: refusal.message, interpolation: { escapeValue: false } })\n : refusal.message\n}\n\n/** The map a reader asked: the active one, or the candidate, which only those who may change it preview. */\nasync function mapAsked(map: FigureTypeMapState | undefined, context: ResolverContext): Promise<FigureTypeMapState.ACTIVE | FigureTypeMapState.CANDIDATE> {\n if (map !== FigureTypeMapState.CANDIDATE) return FigureTypeMapState.ACTIVE\n const { domain, user, unsafeIP, prohibitedPrivileges } = context.state\n const allowed = await checkPermission({ category: 'figure-library', privilege: 'mutation', owner: true }, user, domain, unsafeIP, prohibitedPrivileges)\n if (!allowed) throw new Refusal('figure-type-map-preview-denied', {}, 'previewing the candidate type map needs the right to change it.')\n return FigureTypeMapState.CANDIDATE\n}\n\n/** The most bytes one package upload may carry. */\nconst PACKAGE_MAX_BYTES = 64 * 1024 * 1024\n\nasync function bytesOf(file: FileUpload): Promise<Buffer> {\n const chunks: Buffer[] = []\n let size = 0\n for await (const chunk of file.createReadStream()) {\n size += chunk.length\n if (size > PACKAGE_MAX_BYTES) throw new Refusal('figure-package-too-large', { max: PACKAGE_MAX_BYTES }, 'a figure package is at most {max} bytes.')\n chunks.push(Buffer.from(chunk))\n }\n return Buffer.concat(chunks)\n}\n\n/**\n * The library and the type map of a board server (ADR-0114). Reading is `figure-library` query; changing is its\n * mutation. Boards ask `figureBlueprints` under `figure-published`, the door every figure consumer asks through.\n */\n@Resolver()\n@UseMiddleware(SpeakRefusals)\nexport class FigureLibraryResolver {\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => FigureLibraryReleaseList, { description: 'Lists the releases imported into this domain.' })\n async figureLibraryReleases(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<FigureLibraryReleaseList> {\n const { domain, tx } = context.state\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(FigureLibraryRelease, tx),\n params,\n domain,\n alias: 'release',\n searchables: ['ref', 'name', 'description', 'category']\n })\n const [items, total] = await queryBuilder.getManyAndCount()\n const manager = tx ?? getRepository(FigureLibraryRelease).manager\n for (const item of items) await freshen(manager, item)\n return { items, total }\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [FigureTypeMap], { description: 'The type map releases of this domain, newest first.' })\n async figureTypeMaps(@Ctx() context: ResolverContext): Promise<FigureTypeMap[]> {\n const { domain } = context.state\n return await getRepository(FigureTypeMap).find({ where: { domain: { id: domain.id } }, order: { version: 'DESC' } })\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [FigureTypeMapEntry], { description: 'The lines of one type map release, with the release each draws with.' })\n async figureTypeMapEntries(@Arg('version', type => Int) version: number, @Ctx() context: ResolverContext): Promise<FigureTypeMapEntry[]> {\n const { domain } = context.state\n const map = await getRepository(FigureTypeMap).findOne({ where: { domain: { id: domain.id }, version } })\n return map ? await entriesOf(getRepository(FigureTypeMap).manager, map) : []\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, {\n nullable: true,\n description: 'The check before activation: the candidate against the active map and every board of the domain. Null without a candidate.'\n })\n async figureTypeMapCheck(@Ctx() context: ResolverContext): Promise<any> {\n const { domain } = context.state\n return await typeMapCheck(getRepository(FigureTypeMap).manager, domain)\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, { nullable: true, description: 'What one board needs from the active type map: each figure, its status and node count.' })\n async figureBoardRequirements(@Arg('boardId') boardId: string, @Ctx() context: ResolverContext): Promise<any> {\n const { domain } = context.state\n return await boardRequirements(getRepository(FigureTypeMap).manager, domain, boardId)\n }\n\n @Directive('@privilege(category: \"figure-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, {\n description:\n 'Figures a board asks for together by full name {namespace}/{type}, answered from one type map release: { release: { version, revision }, items: [{ type, ref, asset }], refused: [{ type, code, message }] }.'\n })\n async figureBlueprints(\n @Arg('types', type => [String], { description: 'Full figure names {namespace}/{type}. At most 500.' }) types: string[],\n @Ctx() context: ResolverContext,\n @Arg('map', type => FigureTypeMapState, { nullable: true, description: 'ACTIVE (default) or CANDIDATE for a preview.' })\n map?: FigureTypeMapState\n ): Promise<any> {\n const { domain } = context.state\n const state = await mapAsked(map, context)\n return await blueprintsOf(getRepository(FigureTypeMap).manager, domain, types, state, refusal => plainTextOf(refusal, context))\n }\n\n @Directive('@privilege(category: \"figure-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, {\n description:\n 'Carrier types live data names by CARRIERTYPE code, answered from one type map release (ADR-0123): { release: { version, revision }, items: [{ carrierType, name, ref, dimensions: { width, length, height } }], refused: [{ carrierType, code, message, refs? }] }.'\n })\n async figureCarrierTypes(\n @Arg('carrierTypes', type => [String], { description: 'CARRIERTYPE codes, compared trimmed and upper case. At most 500.' }) carrierTypes: string[],\n @Ctx() context: ResolverContext,\n @Arg('map', type => FigureTypeMapState, { nullable: true, description: 'ACTIVE (default) or CANDIDATE for a preview.' })\n map?: FigureTypeMapState\n ): Promise<any> {\n const { domain } = context.state\n const state = await mapAsked(map, context)\n return await carrierTypesOf(getRepository(FigureTypeMap).manager, domain, carrierTypes, state, refusal => plainTextOf(refusal, context))\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureImportResult, { description: 'Imports a figure package into this domain library and its candidate type map.' })\n async importFigurePackage(@Arg('file', () => GraphQLUpload) file: FileUpload, @Ctx() context: ResolverContext): Promise<FigureImportResult> {\n const { domain, user, tx } = context.state\n const upload = await file\n assertPackageName(upload.filename)\n return await importFigurePackage(tx, domain, user, await bytesOf(upload), upload.filename)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureTypeMap, { description: 'Replaces the lines of the candidate type map. Each save raises its revision.' })\n async saveFigureTypeMapCandidate(\n @Arg('lines', type => [FigureTypeMapLineInput]) lines: FigureTypeMapLineInput[],\n @Ctx() context: ResolverContext,\n @Arg('description', { nullable: true }) description?: string\n ): Promise<FigureTypeMap> {\n const { domain, user, tx } = context.state\n return await saveCandidate(tx, domain, user, lines, description)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureTypeMap, { description: 'Activates a type map release: the candidate, or an archived one to roll back.' })\n async activateFigureTypeMap(@Arg('version', type => Int) version: number, @Ctx() context: ResolverContext): Promise<FigureTypeMap> {\n const { domain, user, tx } = context.state\n return await activate(tx, domain, user, version)\n }\n}\n"]}
1
+ {"version":3,"file":"figure-library-resolver.js","sourceRoot":"","sources":["../../server/service/figure-library-resolver.ts"],"names":[],"mappings":";;;;AAAA,+CAAkG;AAClG,qDAA6C;AAE7C,+FAA2D;AAE3D,iDAAmI;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,wBAAS,EAAC,yFAAyF,CAAC;IACpG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,yCAAkB,EAAE,EAAE,WAAW,EAAE,oIAAoI,EAAE,CAAC;IACpK,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,GAAG,EAAE,CAAC,0BAAa,CAAC,CAAA;IAAoB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAKnF;AAKK;IAHL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,wBAAS,EAAC,yFAAyF,CAAC;IACpG,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,0CAAkB,EAAE,EAAE,WAAW,EAAE,6DAA6D,EAAE,CAAC;IAErH,mBAAA,IAAA,kBAAG,EAAC,MAAM,EAAE,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC,CAAA;IACpE,mBAAA,IAAA,kBAAG,EAAC,WAAW,EAAE,EAAE,WAAW,EAAE,yCAAyC,EAAE,CAAC,CAAA;IAC5E,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;gEAIP;gCAnHU,qBAAqB;IAFjC,IAAA,uBAAQ,GAAE;IACV,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,qBAAqB,CAoHjC","sourcesContent":["import { Arg, Args, Ctx, Directive, Mutation, Query, Resolver, UseMiddleware } from 'type-graphql'\nimport { GraphQLJSON } from 'graphql-scalars'\nimport type { FileUpload } from 'graphql-upload/GraphQLUpload.js'\nimport GraphQLUpload from 'graphql-upload/GraphQLUpload.js'\n\nimport { getQueryBuilderFromListParams, getRepository, ListParam, Refusal, refusalKey, SpeakRefusals } from '@things-factory/shell'\n\nimport { FigureLibraryRelease } from './figure-library-release/figure-library-release'\nimport { FigureTypeMapEntry } from './figure-type-map/figure-type-map-entry'\nimport { FigureImportResult, FigureLibraryFacets, FigureLibraryFigureList, FigureLibraryReleaseList } from './figure-library-types'\nimport { figureFacetsOf, figuresOf, releasesOfName } from './library/figures'\nimport { blueprintsOf } from './library/blueprints'\nimport { carrierTypesOf } from './library/carriers'\nimport { assertPackageName, importFigurePackage } from './library/import'\nimport { boardRequirements, freshen } from './library/inspection'\nimport { chooseRelease, linesOf } from './library/type-map'\n\n/**\n * A refusal in the asker's language as plain text: a board draws it on a canvas, not into HTML, so the values in it\n * (a name with `/`) are not escaped.\n */\nfunction plainTextOf(refusal: Refusal, context: any): string {\n return context.t\n ? context.t(refusalKey(refusal.code), { ...refusal.params, defaultValue: refusal.message, interpolation: { escapeValue: false } })\n : refusal.message\n}\n\n/** The most bytes one package upload may carry. */\nconst PACKAGE_MAX_BYTES = 64 * 1024 * 1024\n\nasync function bytesOf(file: FileUpload): Promise<Buffer> {\n const chunks: Buffer[] = []\n let size = 0\n for await (const chunk of file.createReadStream()) {\n size += chunk.length\n if (size > PACKAGE_MAX_BYTES) throw new Refusal('figure-package-too-large', { max: PACKAGE_MAX_BYTES }, 'a figure package is at most {max} bytes.')\n chunks.push(Buffer.from(chunk))\n }\n return Buffer.concat(chunks)\n}\n\n/**\n * The library and the type map of a board server (ADR-0114). Reading is `figure-library` query; changing is its\n * mutation. Boards ask `figureBlueprints` under `figure-published`, the door every figure consumer asks through.\n */\n@Resolver()\n@UseMiddleware(SpeakRefusals)\nexport class FigureLibraryResolver {\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => FigureLibraryReleaseList, { description: 'Lists the releases imported into this domain.' })\n async figureLibraryReleases(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<FigureLibraryReleaseList> {\n const { domain, tx } = context.state\n const queryBuilder = getQueryBuilderFromListParams({\n repository: getRepository(FigureLibraryRelease, tx),\n params,\n domain,\n alias: 'release',\n searchables: ['ref', 'name', 'description', 'category']\n })\n const [items, total] = await queryBuilder.getManyAndCount()\n const manager = tx ?? getRepository(FigureLibraryRelease).manager\n for (const item of items) await freshen(manager, item)\n return { items, total }\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => FigureLibraryFigureList, {\n description: 'Imported figures, one per full name, with the release each draws with. Filters: category, capability (\"-\" for none), name (search).'\n })\n async figureLibraryFigures(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<FigureLibraryFigureList> {\n const { domain } = context.state\n const value = (name: string) => {\n const found = params.filters?.find(filter => filter.name === name)?.value\n return Array.isArray(found) ? found[0] : found ?? undefined\n }\n const manager = getRepository(FigureTypeMapEntry).manager\n const result = await figuresOf(manager, domain, {\n category: value('category'),\n capability: value('capability'),\n search: value('name'),\n page: params.pagination?.page,\n limit: params.pagination?.limit\n })\n for (const item of result.items) {\n if (item.release) await freshen(manager, item.release)\n await freshen(manager, item.latest)\n }\n return result\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => FigureLibraryFacets, { description: 'The categories and capabilities the figure filters offer.' })\n async figureLibraryFacets(@Ctx() context: ResolverContext): Promise<FigureLibraryFacets> {\n return await figureFacetsOf(getRepository(FigureTypeMapEntry).manager, context.state.domain)\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [FigureLibraryRelease], { description: 'Every imported release of one full figure name, newest first.' })\n async figureLibraryReleasesOf(@Arg('name') name: string, @Ctx() context: ResolverContext): Promise<FigureLibraryRelease[]> {\n return await releasesOfName(getRepository(FigureLibraryRelease).manager, context.state.domain, name)\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => [FigureTypeMapEntry], { description: 'The type map of this domain: one line per full figure name, with the release it draws with.' })\n async figureTypeMap(@Ctx() context: ResolverContext): Promise<FigureTypeMapEntry[]> {\n const { domain } = context.state\n return await linesOf(getRepository(FigureTypeMapEntry).manager, domain)\n }\n\n @Directive('@privilege(category: \"figure-library\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, { nullable: true, description: 'What one board needs from the type map: each figure, its status and node count.' })\n async figureBoardRequirements(@Arg('boardId') boardId: string, @Ctx() context: ResolverContext): Promise<any> {\n const { domain } = context.state\n return await boardRequirements(getRepository(FigureTypeMapEntry).manager, domain, boardId)\n }\n\n @Directive('@privilege(category: \"figure-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, {\n description:\n 'Figures a board asks for together by full name {namespace}/{type}, answered from the type map: { items: [{ type, ref, asset }], refused: [{ type, code, message }] }.'\n })\n async figureBlueprints(\n @Arg('types', type => [String], { description: 'Full figure names {namespace}/{type}. At most 500.' }) types: string[],\n @Ctx() context: ResolverContext\n ): Promise<any> {\n const { domain } = context.state\n return await blueprintsOf(getRepository(FigureTypeMapEntry).manager, domain, types, refusal => plainTextOf(refusal, context))\n }\n\n @Directive('@privilege(category: \"figure-published\", privilege: \"query\", domainOwnerGranted: true)')\n @Query(returns => GraphQLJSON, {\n description:\n 'Carrier types live data names by CARRIERTYPE code, answered from the type map (ADR-0123): { items: [{ carrierType, name, ref, dimensions: { width, length, height } }], refused: [{ carrierType, code, message, refs? }] }.'\n })\n async figureCarrierTypes(\n @Arg('carrierTypes', type => [String], { description: 'CARRIERTYPE codes, compared trimmed and upper case. At most 500.' }) carrierTypes: string[],\n @Ctx() context: ResolverContext\n ): Promise<any> {\n const { domain } = context.state\n return await carrierTypesOf(getRepository(FigureTypeMapEntry).manager, domain, carrierTypes, refusal => plainTextOf(refusal, context))\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureImportResult, { description: 'Imports a figure package into this domain library. A release newer than the one its name draws with becomes the one it draws with.' })\n async importFigurePackage(@Arg('file', () => GraphQLUpload) file: FileUpload, @Ctx() context: ResolverContext): Promise<FigureImportResult> {\n const { domain, user, tx } = context.state\n const upload = await file\n assertPackageName(upload.filename)\n return await importFigurePackage(tx, domain, user, await bytesOf(upload), upload.filename)\n }\n\n @Directive('@transaction')\n @Directive('@privilege(category: \"figure-library\", privilege: \"mutation\", domainOwnerGranted: true)')\n @Mutation(returns => FigureTypeMapEntry, { description: 'Chooses the imported release a full figure name draws with.' })\n async chooseFigureRelease(\n @Arg('name', { description: 'Full figure name {namespace}/{type}.' }) name: string,\n @Arg('releaseId', { description: 'Id of an imported release of that name.' }) releaseId: string,\n @Ctx() context: ResolverContext\n ): Promise<FigureTypeMapEntry> {\n const { domain, user, tx } = context.state\n return await chooseRelease(tx, domain, user, name, releaseId)\n }\n}\n"]}
@@ -3,10 +3,6 @@ export declare class FigureLibraryReleaseList {
3
3
  items: FigureLibraryRelease[];
4
4
  total: number;
5
5
  }
6
- export declare class FigureTypeMapLineInput {
7
- name: string;
8
- releaseId: string;
9
- }
10
6
  export declare class FigureImportOutcome {
11
7
  ref: string;
12
8
  outcome: string;
@@ -21,3 +17,20 @@ export declare class FigureImportResult {
21
17
  problems: FigureImportProblem[];
22
18
  outcomes: FigureImportOutcome[];
23
19
  }
20
+ export declare class FigureLibraryFigure {
21
+ name: string;
22
+ release: FigureLibraryRelease | null;
23
+ latest: FigureLibraryRelease;
24
+ latestVersion: number;
25
+ releaseCount: number;
26
+ }
27
+ export declare class FigureLibraryFigureList {
28
+ items: FigureLibraryFigure[];
29
+ total: number;
30
+ }
31
+ export declare class FigureLibraryFacets {
32
+ categories: string[];
33
+ uncategorized: boolean;
34
+ capabilities: string[];
35
+ incapable: boolean;
36
+ }