@things-factory/figure-library 10.1.135 → 10.1.141
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.
- package/dist-client/pages/figure-library-page.js +2 -1
- package/dist-client/pages/figure-library-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/figure-library-release/figure-library-release.d.ts +9 -2
- package/dist-server/service/figure-library-release/figure-library-release.js +13 -2
- package/dist-server/service/figure-library-release/figure-library-release.js.map +1 -1
- package/dist-server/service/figure-library-resolver.d.ts +1 -0
- package/dist-server/service/figure-library-resolver.js +30 -7
- package/dist-server/service/figure-library-resolver.js.map +1 -1
- package/dist-server/service/index.d.ts +1 -0
- package/dist-server/service/index.js +1 -0
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/library/carriers.d.ts +43 -0
- package/dist-server/service/library/carriers.js +59 -0
- package/dist-server/service/library/carriers.js.map +1 -0
- package/dist-server/service/library/derived.d.ts +11 -3
- package/dist-server/service/library/derived.js +12 -4
- package/dist-server/service/library/derived.js.map +1 -1
- package/dist-server/service/library/inspection.d.ts +7 -0
- package/dist-server/service/library/inspection.js +6 -1
- package/dist-server/service/library/inspection.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/translations/en.json +9 -0
- package/translations/ko.json +9 -0
|
@@ -11,8 +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`
|
|
15
|
-
* server's kernel is another version than the one that checked them. There is no delete
|
|
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.
|
|
16
17
|
*/
|
|
17
18
|
export declare class FigureLibraryRelease {
|
|
18
19
|
readonly id?: string;
|
|
@@ -37,6 +38,12 @@ export declare class FigureLibraryRelease {
|
|
|
37
38
|
checkedKernel?: string;
|
|
38
39
|
width?: number;
|
|
39
40
|
depth?: number;
|
|
41
|
+
carrierType?: string;
|
|
42
|
+
carrierDimensions?: {
|
|
43
|
+
width: number;
|
|
44
|
+
length: number;
|
|
45
|
+
height: number;
|
|
46
|
+
};
|
|
40
47
|
dependencies?: FigureLibraryDependency[];
|
|
41
48
|
deprecated: boolean;
|
|
42
49
|
supersededBy?: string;
|
|
@@ -11,8 +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`
|
|
15
|
-
* server's kernel is another version than the one that checked them. There is no delete
|
|
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.
|
|
16
17
|
*/
|
|
17
18
|
let FigureLibraryRelease = class FigureLibraryRelease {
|
|
18
19
|
};
|
|
@@ -126,6 +127,16 @@ tslib_1.__decorate([
|
|
|
126
127
|
(0, type_graphql_1.Field)(type => type_graphql_1.Float, { nullable: true, description: 'Derived: authored depth (size.z) in mm. Null when unread.' }),
|
|
127
128
|
tslib_1.__metadata("design:type", Number)
|
|
128
129
|
], FigureLibraryRelease.prototype, "depth", void 0);
|
|
130
|
+
tslib_1.__decorate([
|
|
131
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
132
|
+
(0, type_graphql_1.Field)({ nullable: true, description: 'Derived: the CARRIERTYPE code a carrier figure declares, trimmed and upper case. Null when none.' }),
|
|
133
|
+
tslib_1.__metadata("design:type", String)
|
|
134
|
+
], FigureLibraryRelease.prototype, "carrierType", void 0);
|
|
135
|
+
tslib_1.__decorate([
|
|
136
|
+
(0, typeorm_1.Column)('simple-json', { nullable: true, default: null }),
|
|
137
|
+
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'Derived: the declared physical size of a carrier figure in mm, { width, length, height }.' }),
|
|
138
|
+
tslib_1.__metadata("design:type", Object)
|
|
139
|
+
], FigureLibraryRelease.prototype, "carrierDimensions", void 0);
|
|
129
140
|
tslib_1.__decorate([
|
|
130
141
|
(0, typeorm_1.Column)('simple-json', { nullable: true, default: null }),
|
|
131
142
|
(0, type_graphql_1.Field)(type => graphql_scalars_1.GraphQLJSON, { nullable: true, description: 'Files the release depends on: [{ hash, role, size, contentType }].' }),
|
|
@@ -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;;;;;;GAMG;AAQI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CA6IhC,CAAA;AA7IY,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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AAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;sCACxE,gBAAI;qDAAA;AAGd;IADC,IAAA,oBAAU,EAAC,CAAC,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC;;uDAC7C;AAIlB;IAFC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,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;+BA5IP,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,CA6IhC","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` are derived, recomputed when this\n * server's kernel is another version than the one that checked them. 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 => 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;CAqJhC,CAAA;AArJY,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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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"]}
|
|
@@ -14,6 +14,7 @@ export declare class FigureLibraryResolver {
|
|
|
14
14
|
figureTypeMapCheck(context: ResolverContext): Promise<any>;
|
|
15
15
|
figureBoardRequirements(boardId: string, context: ResolverContext): Promise<any>;
|
|
16
16
|
figureBlueprints(types: string[], context: ResolverContext, map?: FigureTypeMapState): Promise<any>;
|
|
17
|
+
figureCarrierTypes(carrierTypes: string[], context: ResolverContext, map?: FigureTypeMapState): Promise<any>;
|
|
17
18
|
importFigurePackage(file: FileUpload, context: ResolverContext): Promise<FigureImportResult>;
|
|
18
19
|
saveFigureTypeMapCandidate(lines: FigureTypeMapLineInput[], context: ResolverContext, description?: string): Promise<FigureTypeMap>;
|
|
19
20
|
activateFigureTypeMap(version: number, context: ResolverContext): Promise<FigureTypeMap>;
|
|
@@ -12,6 +12,7 @@ const figure_type_map_1 = require("./figure-type-map/figure-type-map");
|
|
|
12
12
|
const figure_type_map_entry_1 = require("./figure-type-map/figure-type-map-entry");
|
|
13
13
|
const figure_library_types_1 = require("./figure-library-types");
|
|
14
14
|
const blueprints_1 = require("./library/blueprints");
|
|
15
|
+
const carriers_1 = require("./library/carriers");
|
|
15
16
|
const import_1 = require("./library/import");
|
|
16
17
|
const inspection_1 = require("./library/inspection");
|
|
17
18
|
const type_map_1 = require("./library/type-map");
|
|
@@ -24,6 +25,16 @@ function plainTextOf(refusal, context) {
|
|
|
24
25
|
? context.t((0, shell_1.refusalKey)(refusal.code), { ...refusal.params, defaultValue: refusal.message, interpolation: { escapeValue: false } })
|
|
25
26
|
: refusal.message;
|
|
26
27
|
}
|
|
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
|
+
}
|
|
27
38
|
/** The most bytes one package upload may carry. */
|
|
28
39
|
const PACKAGE_MAX_BYTES = 64 * 1024 * 1024;
|
|
29
40
|
async function bytesOf(file) {
|
|
@@ -75,15 +86,15 @@ let FigureLibraryResolver = class FigureLibraryResolver {
|
|
|
75
86
|
return await (0, inspection_1.boardRequirements)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain, boardId);
|
|
76
87
|
}
|
|
77
88
|
async figureBlueprints(types, context, map) {
|
|
78
|
-
const { domain
|
|
79
|
-
const state = map
|
|
80
|
-
if (state === figure_type_map_1.FigureTypeMapState.CANDIDATE) {
|
|
81
|
-
const allowed = await (0, auth_base_1.checkPermission)({ category: 'figure-library', privilege: 'mutation', owner: true }, user, domain, unsafeIP, prohibitedPrivileges);
|
|
82
|
-
if (!allowed)
|
|
83
|
-
throw new shell_1.Refusal('figure-type-map-preview-denied', {}, 'previewing the candidate type map needs the right to change it.');
|
|
84
|
-
}
|
|
89
|
+
const { domain } = context.state;
|
|
90
|
+
const state = await mapAsked(map, context);
|
|
85
91
|
return await (0, blueprints_1.blueprintsOf)((0, shell_1.getRepository)(figure_type_map_1.FigureTypeMap).manager, domain, types, state, refusal => plainTextOf(refusal, context));
|
|
86
92
|
}
|
|
93
|
+
async figureCarrierTypes(carrierTypes, context, map) {
|
|
94
|
+
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));
|
|
97
|
+
}
|
|
87
98
|
async importFigurePackage(file, context) {
|
|
88
99
|
const { domain, user, tx } = context.state;
|
|
89
100
|
const upload = await file;
|
|
@@ -158,6 +169,18 @@ tslib_1.__decorate([
|
|
|
158
169
|
tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
|
|
159
170
|
tslib_1.__metadata("design:returntype", Promise)
|
|
160
171
|
], FigureLibraryResolver.prototype, "figureBlueprints", null);
|
|
172
|
+
tslib_1.__decorate([
|
|
173
|
+
(0, type_graphql_1.Directive)('@privilege(category: "figure-published", privilege: "query", domainOwnerGranted: true)'),
|
|
174
|
+
(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? }] }.'
|
|
176
|
+
}),
|
|
177
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('carrierTypes', type => [String], { description: 'CARRIERTYPE codes, compared trimmed and upper case. At most 500.' })),
|
|
178
|
+
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
|
+
tslib_1.__metadata("design:type", Function),
|
|
181
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object, String]),
|
|
182
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
183
|
+
], FigureLibraryResolver.prototype, "figureCarrierTypes", null);
|
|
161
184
|
tslib_1.__decorate([
|
|
162
185
|
(0, type_graphql_1.Directive)('@transaction'),
|
|
163
186
|
(0, type_graphql_1.Directive)('@privilege(category: "figure-library", privilege: "mutation", domainOwnerGranted: true)'),
|
|
@@ -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,6CAAyE;AACzE,qDAA+E;AAC/E,iDAAuE;AAEvE;;;GAGG;AACH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,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;gCAlGU,qBAAqB;IAFjC,IAAA,uBAAQ,GAAE;IACV,IAAA,4BAAa,EAAC,qBAAa,CAAC;GAChB,qBAAqB,CAmGjC","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 { 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 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, user, unsafeIP, prohibitedPrivileges } = context.state\n const state = map === FigureTypeMapState.CANDIDATE ? FigureTypeMapState.CANDIDATE : FigureTypeMapState.ACTIVE\n if (state === FigureTypeMapState.CANDIDATE) {\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 }\n return await blueprintsOf(getRepository(FigureTypeMap).manager, domain, types, 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,+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,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,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"]}
|
|
@@ -8,6 +8,7 @@ export * from './figure-type-map/figure-type-map-entry';
|
|
|
8
8
|
export * from './figure-library-types';
|
|
9
9
|
export * from './figure-library-resolver';
|
|
10
10
|
export * from './library/blueprints';
|
|
11
|
+
export * from './library/carriers';
|
|
11
12
|
export * from './library/board-walk';
|
|
12
13
|
export * from './library/derived';
|
|
13
14
|
export * from './library/import';
|
|
@@ -16,6 +16,7 @@ tslib_1.__exportStar(require("./figure-type-map/figure-type-map-entry"), exports
|
|
|
16
16
|
tslib_1.__exportStar(require("./figure-library-types"), exports);
|
|
17
17
|
tslib_1.__exportStar(require("./figure-library-resolver"), exports);
|
|
18
18
|
tslib_1.__exportStar(require("./library/blueprints"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./library/carriers"), exports);
|
|
19
20
|
tslib_1.__exportStar(require("./library/board-walk"), exports);
|
|
20
21
|
tslib_1.__exportStar(require("./library/derived"), exports);
|
|
21
22
|
tslib_1.__exportStar(require("./library/import"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,4FAAsF;AACtF,uEAAiE;AACjE,mFAA4E;AAC5E,uEAAiE;AAEjE,0FAA+D;AAC/D,4EAAiD;AACjD,kFAAuD;AACvD,iEAAsC;AACtC,oEAAyC;AACzC,+DAAoC;AACpC,+DAAoC;AACpC,4DAAiC;AACjC,2DAAgC;AAChC,+DAAoC;AACpC,kEAAuC;AACvC,6DAAkC;AAElC,0HAA0H;AAC7G,QAAA,QAAQ,GAAG,CAAC,6CAAoB,EAAE,+BAAa,EAAE,0CAAkB,CAAC,CAAA;AAEpE,QAAA,MAAM,GAAG,EAAE,eAAe,EAAE,CAAC,+CAAqB,CAAC,EAAE,CAAA","sourcesContent":["/*\n * The board server's own figures (ADR-0114): the library of imported releases and the domain type map.\n * Each source file is named rather than re-exporting folder barrels.\n */\nimport { FigureLibraryRelease } from './figure-library-release/figure-library-release'\nimport { FigureTypeMap } from './figure-type-map/figure-type-map'\nimport { FigureTypeMapEntry } from './figure-type-map/figure-type-map-entry'\nimport { FigureLibraryResolver } from './figure-library-resolver'\n\nexport * from './figure-library-release/figure-library-release'\nexport * from './figure-type-map/figure-type-map'\nexport * from './figure-type-map/figure-type-map-entry'\nexport * from './figure-library-types'\nexport * from './figure-library-resolver'\nexport * from './library/blueprints'\nexport * from './library/board-walk'\nexport * from './library/derived'\nexport * from './library/import'\nexport * from './library/inspection'\nexport * from './library/library-files'\nexport * from './library/type-map'\n\n/* The shell builds the database and the schema from these two names; a module without them has no tables and no doors. */\nexport const entities = [FigureLibraryRelease, FigureTypeMap, FigureTypeMapEntry]\n\nexport const schema = { resolverClasses: [FigureLibraryResolver] }\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA;;;GAGG;AACH,4FAAsF;AACtF,uEAAiE;AACjE,mFAA4E;AAC5E,uEAAiE;AAEjE,0FAA+D;AAC/D,4EAAiD;AACjD,kFAAuD;AACvD,iEAAsC;AACtC,oEAAyC;AACzC,+DAAoC;AACpC,6DAAkC;AAClC,+DAAoC;AACpC,4DAAiC;AACjC,2DAAgC;AAChC,+DAAoC;AACpC,kEAAuC;AACvC,6DAAkC;AAElC,0HAA0H;AAC7G,QAAA,QAAQ,GAAG,CAAC,6CAAoB,EAAE,+BAAa,EAAE,0CAAkB,CAAC,CAAA;AAEpE,QAAA,MAAM,GAAG,EAAE,eAAe,EAAE,CAAC,+CAAqB,CAAC,EAAE,CAAA","sourcesContent":["/*\n * The board server's own figures (ADR-0114): the library of imported releases and the domain type map.\n * Each source file is named rather than re-exporting folder barrels.\n */\nimport { FigureLibraryRelease } from './figure-library-release/figure-library-release'\nimport { FigureTypeMap } from './figure-type-map/figure-type-map'\nimport { FigureTypeMapEntry } from './figure-type-map/figure-type-map-entry'\nimport { FigureLibraryResolver } from './figure-library-resolver'\n\nexport * from './figure-library-release/figure-library-release'\nexport * from './figure-type-map/figure-type-map'\nexport * from './figure-type-map/figure-type-map-entry'\nexport * from './figure-library-types'\nexport * from './figure-library-resolver'\nexport * from './library/blueprints'\nexport * from './library/carriers'\nexport * from './library/board-walk'\nexport * from './library/derived'\nexport * from './library/import'\nexport * from './library/inspection'\nexport * from './library/library-files'\nexport * from './library/type-map'\n\n/* The shell builds the database and the schema from these two names; a module without them has no tables and no doors. */\nexport const entities = [FigureLibraryRelease, FigureTypeMap, FigureTypeMapEntry]\n\nexport const schema = { resolverClasses: [FigureLibraryResolver] }\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { EntityManager } from 'typeorm';
|
|
2
|
+
import { Refusal } from '@things-factory/shell';
|
|
3
|
+
import { FigureLibraryRelease } from '../figure-library-release/figure-library-release';
|
|
4
|
+
import { FigureTypeMap, FigureTypeMapState } from '../figure-type-map/figure-type-map';
|
|
5
|
+
export declare const FIGURE_CARRIER_TYPES_MAX = 500;
|
|
6
|
+
/** The lines of one map whose releases declare a carrier, by the CARRIERTYPE code they declare. */
|
|
7
|
+
export interface CarrierLine {
|
|
8
|
+
/** Full figure name {namespace}/{type}: the map's key, kept apart from the code. */
|
|
9
|
+
name: string;
|
|
10
|
+
release: FigureLibraryRelease;
|
|
11
|
+
}
|
|
12
|
+
export interface CarrierTypesAnswer {
|
|
13
|
+
release: {
|
|
14
|
+
version: number;
|
|
15
|
+
revision: number;
|
|
16
|
+
} | null;
|
|
17
|
+
items: {
|
|
18
|
+
carrierType: string;
|
|
19
|
+
name: string;
|
|
20
|
+
ref: string;
|
|
21
|
+
dimensions: {
|
|
22
|
+
width: number;
|
|
23
|
+
length: number;
|
|
24
|
+
height: number;
|
|
25
|
+
};
|
|
26
|
+
}[];
|
|
27
|
+
refused: {
|
|
28
|
+
carrierType: string;
|
|
29
|
+
code: string;
|
|
30
|
+
message: string;
|
|
31
|
+
refs?: string[];
|
|
32
|
+
}[];
|
|
33
|
+
}
|
|
34
|
+
/** Every carrier code the map's releases declare, with the lines that declare it. A code on more lines than one is a conflict. */
|
|
35
|
+
export declare function carrierLinesOf(tx: EntityManager, map: FigureTypeMap): Promise<Map<string, CarrierLine[]>>;
|
|
36
|
+
/**
|
|
37
|
+
* Carrier types live data names, answered from one type map release (ADR-0123): per code the release whose declaration
|
|
38
|
+
* names it and its physical size, or a refusal with its cause. A code two releases declare is never picked from; it is
|
|
39
|
+
* refused as a conflict naming both. Without a map every code is refused for that.
|
|
40
|
+
*/
|
|
41
|
+
export declare function carrierTypesOf(tx: EntityManager, domain: {
|
|
42
|
+
id: string;
|
|
43
|
+
}, carrierTypes: readonly string[], state: FigureTypeMapState.ACTIVE | FigureTypeMapState.CANDIDATE, speak: (refusal: Refusal) => string): Promise<CarrierTypesAnswer>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FIGURE_CARRIER_TYPES_MAX = void 0;
|
|
4
|
+
exports.carrierLinesOf = carrierLinesOf;
|
|
5
|
+
exports.carrierTypesOf = carrierTypesOf;
|
|
6
|
+
const figure_model_1 = require("@hatiolab/figure-model");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const inspection_1 = require("./inspection");
|
|
9
|
+
const type_map_1 = require("./type-map");
|
|
10
|
+
exports.FIGURE_CARRIER_TYPES_MAX = 500;
|
|
11
|
+
/** Every carrier code the map's releases declare, with the lines that declare it. A code on more lines than one is a conflict. */
|
|
12
|
+
async function carrierLinesOf(tx, map) {
|
|
13
|
+
const byCode = new Map();
|
|
14
|
+
for (const line of await (0, type_map_1.entriesOf)(tx, map)) {
|
|
15
|
+
if (!line.release || line.release.deletedAt)
|
|
16
|
+
continue;
|
|
17
|
+
const release = await (0, inspection_1.freshen)(tx, line.release);
|
|
18
|
+
if (!release.carrierType)
|
|
19
|
+
continue;
|
|
20
|
+
byCode.set(release.carrierType, [...(byCode.get(release.carrierType) ?? []), { name: line.name, release }]);
|
|
21
|
+
}
|
|
22
|
+
return byCode;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Carrier types live data names, answered from one type map release (ADR-0123): per code the release whose declaration
|
|
26
|
+
* names it and its physical size, or a refusal with its cause. A code two releases declare is never picked from; it is
|
|
27
|
+
* refused as a conflict naming both. Without a map every code is refused for that.
|
|
28
|
+
*/
|
|
29
|
+
async function carrierTypesOf(tx, domain, carrierTypes, state, speak) {
|
|
30
|
+
const codes = [...new Set(carrierTypes.map(figure_model_1.normalizeCarrierType).filter(Boolean))];
|
|
31
|
+
if (codes.length > exports.FIGURE_CARRIER_TYPES_MAX) {
|
|
32
|
+
throw new shell_1.Refusal('figure-carrier-types-too-many', { count: codes.length, max: exports.FIGURE_CARRIER_TYPES_MAX }, 'at most {max} carrier types can be asked at once, not {count}.');
|
|
33
|
+
}
|
|
34
|
+
const map = await (0, type_map_1.mapOfState)(tx, domain, state);
|
|
35
|
+
const answer = { release: map ? { version: map.version, revision: map.revision } : null, items: [], refused: [] };
|
|
36
|
+
const refuse = (carrierType, refusal, refs) => answer.refused.push({ carrierType, code: refusal.code, message: speak(refusal), ...(refs ? { refs } : {}) });
|
|
37
|
+
if (!map) {
|
|
38
|
+
for (const carrierType of codes)
|
|
39
|
+
refuse(carrierType, new shell_1.Refusal('figure-carrier-no-type-map', { carrierType }, 'this domain has no type map to find carrier type {carrierType} in.'));
|
|
40
|
+
return answer;
|
|
41
|
+
}
|
|
42
|
+
const lines = await carrierLinesOf(tx, map);
|
|
43
|
+
for (const carrierType of codes) {
|
|
44
|
+
const found = lines.get(carrierType) ?? [];
|
|
45
|
+
if (!found.length) {
|
|
46
|
+
refuse(carrierType, new shell_1.Refusal('figure-carrier-not-in-type-map', { carrierType }, 'no figure in the type map is carrier type {carrierType}.'));
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (found.length > 1) {
|
|
50
|
+
const refs = found.map(line => line.release.ref);
|
|
51
|
+
refuse(carrierType, new shell_1.Refusal('figure-carrier-conflict', { carrierType, refs: refs.join(', ') }, 'carrier type {carrierType} is declared by more than one figure in the type map: {refs}.'), refs);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const [{ name, release }] = found;
|
|
55
|
+
answer.items.push({ carrierType, name, ref: release.ref, dimensions: { ...release.carrierDimensions } });
|
|
56
|
+
}
|
|
57
|
+
return answer;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=carriers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carriers.js","sourceRoot":"","sources":["../../../server/service/library/carriers.ts"],"names":[],"mappings":";;;AA0BA,wCASC;AAOD,wCA0CC;AAlFD,yDAA6D;AAC7D,iDAA+C;AAI/C,6CAAsC;AACtC,yCAAkD;AAErC,QAAA,wBAAwB,GAAG,GAAG,CAAA;AAe3C,kIAAkI;AAC3H,KAAK,UAAU,cAAc,CAAC,EAAiB,EAAE,GAAkB;IACxE,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC/C,KAAK,MAAM,IAAI,IAAI,MAAM,IAAA,oBAAS,EAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAAC;QAC5C,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS;YAAE,SAAQ;QACrD,MAAM,OAAO,GAAG,MAAM,IAAA,oBAAO,EAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;QAC/C,IAAI,CAAC,OAAO,CAAC,WAAW;YAAE,SAAQ;QAClC,MAAM,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AE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,GAAG,OAAO,CAAC,iBAAkB,EAAE,EAAE,CAAC,CAAA;IAC3G,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { EntityManager } from 'typeorm'\n\nimport { normalizeCarrierType } from '@hatiolab/figure-model'\nimport { Refusal } 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 { freshen } from './inspection'\nimport { entriesOf, mapOfState } from './type-map'\n\nexport const FIGURE_CARRIER_TYPES_MAX = 500\n\n/** The lines of one map whose releases declare a carrier, by the CARRIERTYPE code they declare. */\nexport interface CarrierLine {\n /** Full figure name {namespace}/{type}: the map's key, kept apart from the code. */\n name: string\n release: FigureLibraryRelease\n}\n\nexport interface CarrierTypesAnswer {\n release: { version: number; revision: number } | null\n items: { carrierType: string; name: string; ref: string; dimensions: { width: number; length: number; height: number } }[]\n refused: { carrierType: string; code: string; message: string; refs?: string[] }[]\n}\n\n/** Every carrier code the map's releases declare, with the lines that declare it. A code on more lines than one is a conflict. */\nexport async function carrierLinesOf(tx: EntityManager, map: FigureTypeMap): Promise<Map<string, CarrierLine[]>> {\n const byCode = new Map<string, CarrierLine[]>()\n for (const line of await entriesOf(tx, map)) {\n if (!line.release || line.release.deletedAt) continue\n const release = await freshen(tx, line.release)\n if (!release.carrierType) continue\n byCode.set(release.carrierType, [...(byCode.get(release.carrierType) ?? []), { name: line.name, release }])\n }\n return byCode\n}\n\n/**\n * Carrier types live data names, answered from one type map release (ADR-0123): per code the release whose declaration\n * names it and its physical size, or a refusal with its cause. A code two releases declare is never picked from; it is\n * refused as a conflict naming both. Without a map every code is refused for that.\n */\nexport async function carrierTypesOf(\n tx: EntityManager,\n domain: { id: string },\n carrierTypes: readonly string[],\n state: FigureTypeMapState.ACTIVE | FigureTypeMapState.CANDIDATE,\n speak: (refusal: Refusal) => string\n): Promise<CarrierTypesAnswer> {\n const codes = [...new Set(carrierTypes.map(normalizeCarrierType).filter(Boolean))]\n if (codes.length > FIGURE_CARRIER_TYPES_MAX) {\n throw new Refusal('figure-carrier-types-too-many', { count: codes.length, max: FIGURE_CARRIER_TYPES_MAX }, 'at most {max} carrier types can be asked at once, not {count}.')\n }\n const map = await mapOfState(tx, domain, state)\n const answer: CarrierTypesAnswer = { release: map ? { version: map.version, revision: map.revision } : null, items: [], refused: [] }\n const refuse = (carrierType: string, refusal: Refusal, refs?: string[]) =>\n answer.refused.push({ carrierType, code: refusal.code, message: speak(refusal), ...(refs ? { refs } : {}) })\n\n if (!map) {\n for (const carrierType of codes)\n refuse(carrierType, new Refusal('figure-carrier-no-type-map', { carrierType }, 'this domain has no type map to find carrier type {carrierType} in.'))\n return answer\n }\n\n const lines = await carrierLinesOf(tx, map)\n for (const carrierType of codes) {\n const found = lines.get(carrierType) ?? []\n if (!found.length) {\n refuse(carrierType, new Refusal('figure-carrier-not-in-type-map', { carrierType }, 'no figure in the type map is carrier type {carrierType}.'))\n continue\n }\n if (found.length > 1) {\n const refs = found.map(line => line.release.ref)\n refuse(\n carrierType,\n new Refusal('figure-carrier-conflict', { carrierType, refs: refs.join(', ') }, 'carrier type {carrierType} is declared by more than one figure in the type map: {refs}.'),\n refs\n )\n continue\n }\n const [{ name, release }] = found\n answer.items.push({ carrierType, name, ref: release.ref, dimensions: { ...release.carrierDimensions! } })\n }\n return answer\n}\n"]}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
/** What this server derives from a release's source: whether its kernel reads it, and its
|
|
1
|
+
/** What this server derives from a release's source: whether its kernel reads it, its authored size, and its carrier declaration. */
|
|
2
2
|
export interface DerivedOfSource {
|
|
3
3
|
formatSupported: boolean;
|
|
4
4
|
checkedKernel: string;
|
|
5
5
|
width: number | null;
|
|
6
6
|
depth: number | null;
|
|
7
|
+
/** The CARRIERTYPE code a carrier figure declares (ADR-0123), as compared. Null when it declares none or is unread. */
|
|
8
|
+
carrierType: string | null;
|
|
9
|
+
/** Its physical size in mm, as declared. Null with `carrierType`. */
|
|
10
|
+
carrierDimensions: {
|
|
11
|
+
width: number;
|
|
12
|
+
length: number;
|
|
13
|
+
height: number;
|
|
14
|
+
} | null;
|
|
7
15
|
}
|
|
8
16
|
/**
|
|
9
|
-
* Reads a source with this server's kernel. A source it cannot read is kept (ADR-0114 결정 5) and marked; the size
|
|
10
|
-
* then unknown, never guessed.
|
|
17
|
+
* Reads a source with this server's kernel. A source it cannot read is kept (ADR-0114 결정 5) and marked; the size and
|
|
18
|
+
* the carrier declaration are then unknown, never guessed.
|
|
11
19
|
*/
|
|
12
20
|
export declare function derivedOfSource(source: string): DerivedOfSource;
|
|
13
21
|
/** Whether a row's derived values were made by another kernel than this server's and must be made again. */
|
|
@@ -4,18 +4,26 @@ exports.derivedOfSource = derivedOfSource;
|
|
|
4
4
|
exports.derivedIsStale = derivedIsStale;
|
|
5
5
|
const figure_model_1 = require("@hatiolab/figure-model");
|
|
6
6
|
/**
|
|
7
|
-
* Reads a source with this server's kernel. A source it cannot read is kept (ADR-0114 결정 5) and marked; the size
|
|
8
|
-
* then unknown, never guessed.
|
|
7
|
+
* Reads a source with this server's kernel. A source it cannot read is kept (ADR-0114 결정 5) and marked; the size and
|
|
8
|
+
* the carrier declaration are then unknown, never guessed.
|
|
9
9
|
*/
|
|
10
10
|
function derivedOfSource(source) {
|
|
11
11
|
try {
|
|
12
12
|
const asset = (0, figure_model_1.parseFigureAsset)(source);
|
|
13
13
|
(0, figure_model_1.compileFigureAsset)(asset);
|
|
14
14
|
const { width, depth } = authoredPlanOf(asset);
|
|
15
|
-
|
|
15
|
+
const carrier = asset.carrier ?? null;
|
|
16
|
+
return {
|
|
17
|
+
formatSupported: true,
|
|
18
|
+
checkedKernel: figure_model_1.FIGURE_KERNEL_VERSION,
|
|
19
|
+
width,
|
|
20
|
+
depth,
|
|
21
|
+
carrierType: carrier?.type ?? null,
|
|
22
|
+
carrierDimensions: carrier ? { ...carrier.dimensions } : null
|
|
23
|
+
};
|
|
16
24
|
}
|
|
17
25
|
catch {
|
|
18
|
-
return { formatSupported: false, checkedKernel: figure_model_1.FIGURE_KERNEL_VERSION, width: null, depth: null };
|
|
26
|
+
return { formatSupported: false, checkedKernel: figure_model_1.FIGURE_KERNEL_VERSION, width: null, depth: null, carrierType: null, carrierDimensions: null };
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
/** Whether a row's derived values were made by another kernel than this server's and must be made again. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derived.js","sourceRoot":"","sources":["../../../server/service/library/derived.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"derived.js","sourceRoot":"","sources":["../../../server/service/library/derived.ts"],"names":[],"mappings":";;AAkBA,0CAiBC;AAGD,wCAEC;AAxCD,yDAA2J;AAc3J;;;GAGG;AACH,SAAgB,eAAe,CAAC,MAAc;IAC5C,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,IAAA,+BAAgB,EAAC,MAAM,CAAC,CAAA;QACtC,IAAA,iCAAkB,EAAC,KAAK,CAAC,CAAA;QACzB,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QAC9C,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,IAAI,CAAA;QACrC,OAAO;YACL,eAAe,EAAE,IAAI;YACrB,aAAa,EAAE,oCAAqB;YACpC,KAAK;YACL,KAAK;YACL,WAAW,EAAE,OAAO,EAAE,IAAI,IAAI,IAAI;YAClC,iBAAiB,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI;SAC9D,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,aAAa,EAAE,oCAAqB,EAAE,KAAK,EAAE,IAAI,EA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CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAClG,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;IACrF,OAAO,EAAE,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAC3E,CAAC","sourcesContent":["import { compileFigureAsset, FIGURE_KERNEL_VERSION, FIGURE_SIZE_INPUTS, figureTopViewOf, parseFigureAsset, type FigureAsset } from '@hatiolab/figure-model'\n\n/** What this server derives from a release's source: whether its kernel reads it, its authored size, and its carrier declaration. */\nexport interface DerivedOfSource {\n formatSupported: boolean\n checkedKernel: string\n width: number | null\n depth: number | null\n /** The CARRIERTYPE code a carrier figure declares (ADR-0123), as compared. Null when it declares none or is unread. */\n carrierType: string | null\n /** Its physical size in mm, as declared. Null with `carrierType`. */\n carrierDimensions: { width: number; length: number; height: number } | null\n}\n\n/**\n * Reads a source with this server's kernel. A source it cannot read is kept (ADR-0114 결정 5) and marked; the size and\n * the carrier declaration are then unknown, never guessed.\n */\nexport function derivedOfSource(source: string): DerivedOfSource {\n try {\n const asset = parseFigureAsset(source)\n compileFigureAsset(asset)\n const { width, depth } = authoredPlanOf(asset)\n const carrier = asset.carrier ?? null\n return {\n formatSupported: true,\n checkedKernel: FIGURE_KERNEL_VERSION,\n width,\n depth,\n carrierType: carrier?.type ?? null,\n carrierDimensions: carrier ? { ...carrier.dimensions } : null\n }\n } catch {\n return { formatSupported: false, checkedKernel: FIGURE_KERNEL_VERSION, width: null, depth: null, carrierType: null, carrierDimensions: null }\n }\n}\n\n/** Whether a row's derived values were made by another kernel than this server's and must be made again. */\nexport function derivedIsStale(row: { checkedKernel?: string | null }): boolean {\n return row.checkedKernel !== FIGURE_KERNEL_VERSION\n}\n\n/**\n * The plan size a figure is placed at: its size inputs when it declares them (what the scene scales against), else the\n * extent of its top view at the authored size.\n */\nfunction authoredPlanOf(asset: FigureAsset): { width: number | null; depth: number | null } {\n const input = (axis: 'x' | 'z') => {\n const value = asset.designInputs?.[FIGURE_SIZE_INPUTS[axis]]\n return typeof value === 'number' && Number.isFinite(value) && value > 0 ? value : null\n }\n const width = input('x')\n const depth = input('z')\n if (width !== null && depth !== null) return { width, depth }\n\n const points = figureTopViewOf(asset, null).shapes.flatMap(shape => shape.outline)\n if (!points.length) return { width: null, depth: null }\n const span = (i: 0 | 1) => Math.max(...points.map(p => p[i])) - Math.min(...points.map(p => p[i]))\n const round = (value: number) => (value > 0 ? Math.round(value * 1000) / 1000 : null)\n return { width: width ?? round(span(0)), depth: depth ?? round(span(1)) }\n}\n"]}
|
|
@@ -46,6 +46,13 @@ export declare function typeMapCheck(tx: EntityManager, domain: Domain, files?:
|
|
|
46
46
|
deprecated: any[];
|
|
47
47
|
unsupported: any[];
|
|
48
48
|
dependencies: any[];
|
|
49
|
+
carrierConflicts: {
|
|
50
|
+
carrierType: string;
|
|
51
|
+
lines: {
|
|
52
|
+
name: string;
|
|
53
|
+
ref: string;
|
|
54
|
+
}[];
|
|
55
|
+
}[];
|
|
49
56
|
}>;
|
|
50
57
|
export type RequirementStatus = 'drawn' | 'not-in-type-map' | 'release-unavailable' | 'dependency-missing' | 'format-unsupported';
|
|
51
58
|
/**
|
|
@@ -78,8 +78,11 @@ async function typeMapCheck(tx, domain, files) {
|
|
|
78
78
|
const deprecated = [];
|
|
79
79
|
const unsupported = [];
|
|
80
80
|
const dependencies = [];
|
|
81
|
+
const carriers = new Map();
|
|
81
82
|
for (const [name, release] of next) {
|
|
82
83
|
const fresh = await freshen(tx, release);
|
|
84
|
+
if (fresh.carrierType)
|
|
85
|
+
carriers.set(fresh.carrierType, [...(carriers.get(fresh.carrierType) ?? []), { name, ref: fresh.ref }]);
|
|
83
86
|
if (fresh.deprecated)
|
|
84
87
|
deprecated.push({ name, ref: fresh.ref, supersededBy: fresh.supersededBy ?? null, ...at(name) });
|
|
85
88
|
if (!fresh.formatSupported)
|
|
@@ -96,7 +99,9 @@ async function typeMapCheck(tx, domain, files) {
|
|
|
96
99
|
changed,
|
|
97
100
|
deprecated,
|
|
98
101
|
unsupported,
|
|
99
|
-
dependencies
|
|
102
|
+
dependencies,
|
|
103
|
+
/* A CARRIERTYPE code two figures of the candidate declare: live data with it finds no carrier (ADR-0123). Reported, as the rest. */
|
|
104
|
+
carrierConflicts: [...carriers].filter(([, lines]) => lines.length > 1).map(([carrierType, lines]) => ({ carrierType, lines }))
|
|
100
105
|
};
|
|
101
106
|
}
|
|
102
107
|
/** The contract changes between two releases, or `uncheckable` when this server cannot read either. */
|