document-model 6.2.3-dev.93 → 6.2.3-dev.95
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/index.d.ts +63 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1287 -295
- package/dist/index.js.map +1 -1
- package/dist/scalars.d.ts +5 -0
- package/dist/scalars.d.ts.map +1 -1
- package/dist/scalars.js +2 -2
- package/dist/{catalog-6zzASEUv.js → stored-definition-BKTzlNCC.js} +16 -2
- package/dist/stored-definition-BKTzlNCC.js.map +1 -0
- package/dist/tooling.d.mts +70 -7
- package/dist/tooling.d.mts.map +1 -1
- package/dist/tooling.mjs +205 -19
- package/dist/tooling.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/catalog-6zzASEUv.js.map +0 -1
package/dist/scalars.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { a as SCALAR_DEFINITION_VERSION, c as ScalarRepresentation, d as scalarDefinitionVersion, f as ScalarLiteralNode, i as DescribedScalarDefinition, l as ScalarValue, n as getCatalogScalar, o as ScalarCoercion, r as scalarCatalog, s as ScalarDefinition, t as documentModelScalars, u as isScalarDefinition } from "./catalog-B3nJD57s.js";
|
|
2
|
+
import { StoredScalarDefinition } from "@powerhousedao/shared/document-model";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
//#region src/scalars/representation.d.ts
|
|
4
5
|
type JsonRepresentation = Exclude<ScalarRepresentation, "opaque">;
|
|
@@ -34,6 +35,10 @@ type ScalarInput<TName extends string, S extends z.ZodType> = {
|
|
|
34
35
|
};
|
|
35
36
|
export declare function defineScalar<TName extends string, S extends z.ZodType>(input: ScalarInput<TName, S>): DescribedScalarDefinition<TName, z.output<S>>;
|
|
36
37
|
//#endregion
|
|
38
|
+
//#region src/scalars/stored-definition.d.ts
|
|
39
|
+
/** The metadata a stored definition records for a `defineScalar` binding. */
|
|
40
|
+
export declare function storedScalarDefinition(definition: ScalarDefinition): StoredScalarDefinition;
|
|
41
|
+
//#endregion
|
|
37
42
|
export { type DescribedScalarDefinition, SCALAR_DEFINITION_VERSION, type ScalarCoercion, type ScalarDefinition, type ScalarLiteralNode, type ScalarRepresentation, type ScalarValue, documentModelScalars, getCatalogScalar, isScalarDefinition, scalarCatalog, scalarDefinitionVersion };
|
|
38
43
|
export {};
|
|
39
44
|
//# sourceMappingURL=scalars.d.ts.map
|
package/dist/scalars.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalars.d.ts","names":[],"sources":["../src/scalars/representation.ts","../src/scalars/define-scalar.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"scalars.d.ts","names":[],"sources":["../src/scalars/representation.ts","../src/scalars/define-scalar.ts","../src/scalars/stored-definition.ts"],"mappings":";;;;KAKY,qBAAqB,QAAQ;;;KCIpC,0CAA0C;GAAY,cAAc;;KAEpE;EACH;;KAEG;EACH;;KAEG;EACH;;KAEG;EACH;;KAEG;EACH;;KAMG,kBAAkB,UAAU,EAAE,WACjC,gDAEI,gEAEkB,EAAE,MAAM,+BAEJ,EAAE,MAAM;KAI/B,gBAAgB,UAAU,EAAE,yBAAyB,EAAE,OAAO,KAC/D,cACA,kBAAkB,kBAChB,sBACA,EAAE,OAAO,WAAW,oBACL,EAAE,OAAO,KACpB,kBACA,EAAE,OAAO,WAAW,EAAE,MAAM,KAC1B,IACA,oBACJ;KAEH,YAAY,sBAAsB,UAAU,EAAE;EACjD,MAAM;EACN,QAAQ,IAAI,gBAAgB;EAC5B;EACA,UAAU,QAAQ,EAAE,MAAM;;EAE1B,iBAAiB;;wBAwDH,aAAa,sBAAsB,UAAU,EAAE,SAC7D,OAAO,YAAY,OAAO,KACzB,0BAA0B,OAAO,EAAE,OAAO;;;;wBCjH7B,uBACd,YAAY,mBACX"}
|
package/dist/scalars.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as defineCatalogScalar, c as scalarDefinitionVersion, i as scalarCatalog, n as documentModelScalars, o as SCALAR_DEFINITION_VERSION, r as getCatalogScalar, s as isScalarDefinition, t as storedScalarDefinition } from "./stored-definition-BKTzlNCC.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/scalars/representation.ts
|
|
4
4
|
const shapeOfJsonType = {
|
|
@@ -141,6 +141,6 @@ function scalarRepresentation(name, schema, declared) {
|
|
|
141
141
|
return representation;
|
|
142
142
|
}
|
|
143
143
|
//#endregion
|
|
144
|
-
export { SCALAR_DEFINITION_VERSION, defineScalar, documentModelScalars, getCatalogScalar, isScalarDefinition, scalarCatalog, scalarDefinitionVersion };
|
|
144
|
+
export { SCALAR_DEFINITION_VERSION, defineScalar, documentModelScalars, getCatalogScalar, isScalarDefinition, scalarCatalog, scalarDefinitionVersion, storedScalarDefinition };
|
|
145
145
|
|
|
146
146
|
//# sourceMappingURL=scalars.js.map
|
|
@@ -353,6 +353,20 @@ function getCatalogScalar(name) {
|
|
|
353
353
|
}
|
|
354
354
|
const documentModelScalars = Object.freeze(scalarCatalog.filter((definition) => definition.typescriptType !== null && definition.zodSource !== null));
|
|
355
355
|
//#endregion
|
|
356
|
-
|
|
356
|
+
//#region src/scalars/stored-definition.ts
|
|
357
|
+
/** The metadata a stored definition records for a `defineScalar` binding. */
|
|
358
|
+
function storedScalarDefinition(definition) {
|
|
359
|
+
return {
|
|
360
|
+
kind: "powerhouse.scalar",
|
|
361
|
+
formatVersion: 1,
|
|
362
|
+
name: definition.name,
|
|
363
|
+
representation: definition.representation ?? "json",
|
|
364
|
+
description: definition.description ?? "",
|
|
365
|
+
coercion: { source: definition.coercion === void 0 ? "derived" : "explicit" },
|
|
366
|
+
coercionProfile: "catalog-v1"
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
//#endregion
|
|
370
|
+
export { defineCatalogScalar as a, scalarDefinitionVersion as c, scalarCatalog as i, documentModelScalars as n, SCALAR_DEFINITION_VERSION as o, getCatalogScalar as r, isScalarDefinition as s, storedScalarDefinition as t };
|
|
357
371
|
|
|
358
|
-
//# sourceMappingURL=
|
|
372
|
+
//# sourceMappingURL=stored-definition-BKTzlNCC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stored-definition-BKTzlNCC.js","names":["schema","schema","schema","schema","schema","schema"],"sources":["../src/scalars/types.ts","../src/scalars/define-catalog-scalar.ts","../src/scalars/scalar-literal.ts","../src/scalars/declarations/unknown.ts","../src/scalars/declarations/date-time.ts","../src/scalars/pattern.ts","../src/scalars/declarations/address.ts","../src/scalars/declarations/attachment-ref.ts","../src/scalars/coercion.ts","../src/scalars/declarations/amounts.ts","../src/scalars/declarations/amount-tokens.ts","../src/scalars/declarations/ethereum-address.ts","../src/scalars/declarations/email-address.ts","../src/scalars/declarations/amount-percentage.ts","../src/scalars/declarations/date.ts","../src/scalars/declarations/url.ts","../src/scalars/declarations/amount-money.ts","../src/scalars/declarations/olabel.ts","../src/scalars/declarations/currency.ts","../src/scalars/declarations/phid.ts","../src/scalars/declarations/oid.ts","../src/scalars/declarations/amount-fiat.ts","../src/scalars/declarations/amount-currency.ts","../src/scalars/declarations/amount-crypto.ts","../src/scalars/declarations/amount.ts","../src/scalars/declarations/upload.ts","../src/scalars/declarations/json-object.ts","../src/scalars/catalog.ts","../src/scalars/stored-definition.ts"],"sourcesContent":["import type { z } from \"zod\";\nimport type { ScalarLiteralNode } from \"./scalar-literal.js\";\n\nexport const SCALAR_DEFINITION = Symbol.for(\"powerhouse.scalar-definition\");\nexport const SCALAR_DEFINITION_VERSION = 1;\n\n/** The wire shape of a scalar's values. */\nexport type ScalarRepresentation =\n | \"string\"\n | \"number\"\n | \"boolean\"\n | \"json-object\"\n | \"json\"\n | \"opaque\";\n\n/** The GraphQL coercion of a scalar: variables, inline literals, and output. */\nexport type ScalarCoercion<TValue> = {\n readonly parseValue: (input: unknown) => TValue;\n readonly parseLiteral: (node: ScalarLiteralNode) => TValue;\n readonly serialize: (value: unknown) => unknown;\n};\n\nexport type ScalarDefinition<\n TName extends string = string,\n TValue = unknown,\n> = {\n readonly [SCALAR_DEFINITION]: typeof SCALAR_DEFINITION_VERSION;\n readonly name: TName;\n readonly description?: string;\n readonly schema: z.ZodType<TValue>;\n readonly typescriptType: string | null;\n readonly zodSource: string | null;\n readonly example?: TValue;\n /**\n * The wire shape of a value. It picks the literal kinds a derived coercion\n * accepts. A definition from a release before this field lacks it.\n */\n readonly representation?: ScalarRepresentation;\n /** Absent means derived: `schema` runs on every path and only the literal kinds of `representation` parse. */\n readonly coercion?: ScalarCoercion<TValue>;\n};\n\n/** A definition this release made, with its representation filled. */\nexport type DescribedScalarDefinition<\n TName extends string = string,\n TValue = unknown,\n> = ScalarDefinition<TName, TValue> & {\n readonly representation: ScalarRepresentation;\n};\n\nexport type ScalarValue<T> =\n T extends ScalarDefinition<string, infer V> ? V : never;\n\n/** The definition format version `value` is branded with, if it has a brand. */\nexport function scalarDefinitionVersion(value: unknown): unknown {\n return typeof value === \"object\" &&\n value !== null &&\n SCALAR_DEFINITION in value\n ? value[SCALAR_DEFINITION]\n : undefined;\n}\n\nexport function isScalarDefinition(value: unknown): value is ScalarDefinition {\n return scalarDefinitionVersion(value) === SCALAR_DEFINITION_VERSION;\n}\n","import {\n type DescribedScalarDefinition,\n SCALAR_DEFINITION,\n SCALAR_DEFINITION_VERSION,\n} from \"./types.js\";\n\nexport function defineCatalogScalar<TName extends string, TValue>(\n input: Omit<\n DescribedScalarDefinition<TName, TValue>,\n typeof SCALAR_DEFINITION\n >,\n): DescribedScalarDefinition<TName, TValue> {\n return Object.freeze({\n ...input,\n [SCALAR_DEFINITION]: SCALAR_DEFINITION_VERSION,\n } satisfies DescribedScalarDefinition<TName, TValue>);\n}\n","/**\n * Closed literal grammar handed to `parseLiteral`. It mirrors the GraphQL\n * literal kinds the catalog supports so a declaration never needs graphql-js.\n */\nexport type ScalarLiteralNode =\n | { readonly kind: \"string\"; readonly value: string }\n | { readonly kind: \"int\"; readonly value: string }\n | { readonly kind: \"float\"; readonly value: string }\n | { readonly kind: \"boolean\"; readonly value: boolean }\n | { readonly kind: \"null\" }\n | { readonly kind: \"enum\"; readonly value: string }\n | { readonly kind: \"list\"; readonly values: readonly ScalarLiteralNode[] }\n | {\n readonly kind: \"object\";\n readonly fields: readonly {\n readonly name: string;\n readonly value: ScalarLiteralNode;\n }[];\n }\n | { readonly kind: \"variable\"; readonly name: string };\n\nexport class ScalarLiteralVariableError extends TypeError {\n constructor(name: string) {\n super(\n `Variable $${name} cannot appear inside a scalar literal; GraphQL resolves variables before literal coercion.`,\n );\n this.name = \"ScalarLiteralVariableError\";\n }\n}\n\n/** Converts a literal node to its runtime value. A variable anywhere throws. */\nexport function scalarLiteralValue(node: ScalarLiteralNode): unknown {\n switch (node.kind) {\n case \"string\":\n case \"enum\":\n return node.value;\n case \"int\":\n case \"float\":\n return Number(node.value);\n case \"boolean\":\n return node.value;\n case \"null\":\n return null;\n case \"list\":\n return node.values.map(scalarLiteralValue);\n case \"object\":\n return Object.fromEntries(\n node.fields.map((field) => [\n field.name,\n scalarLiteralValue(field.value),\n ]),\n );\n case \"variable\":\n throw new ScalarLiteralVariableError(node.name);\n }\n}\n\nexport function objectFields(\n node: ScalarLiteralNode,\n): ReadonlyMap<string, ScalarLiteralNode> {\n if (node.kind !== \"object\")\n throw new TypeError(\"Value must be an object literal.\");\n return new Map(node.fields.map((field) => [field.name, field.value]));\n}\n\nexport function literalString(\n node: ScalarLiteralNode | undefined,\n field: string,\n): string {\n if (node?.kind !== \"string\")\n throw new TypeError(`${field} must be a string literal.`);\n return node.value;\n}\n\nexport function floatOnlyNumber(\n node: ScalarLiteralNode | undefined,\n field: string,\n): number {\n if (node?.kind !== \"float\")\n throw new TypeError(`${field} must be a float literal.`);\n return Number.parseFloat(node.value);\n}\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { scalarLiteralValue } from \"../scalar-literal.js\";\n\nexport const unknownScalar = defineCatalogScalar({\n name: \"Unknown\",\n typescriptType: \"unknown\",\n zodSource: \"z.unknown()\",\n schema: z.unknown(),\n representation: \"opaque\",\n coercion: {\n parseValue: (value) => value,\n parseLiteral: scalarLiteralValue,\n serialize: (value) => value,\n },\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const dateTimeScalar = defineCatalogScalar({\n example: \"2024-01-01T00:00:00.000Z\",\n name: \"DateTime\",\n typescriptType: \"string\",\n zodSource: \"z.iso.datetime()\",\n schema: z.iso.datetime(),\n representation: \"string\",\n});\n","export function matchesScalarPattern(pattern: RegExp, value: unknown): boolean {\n return Reflect.apply(pattern.test.bind(pattern), undefined, [value]) === true;\n}\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { matchesScalarPattern } from \"../pattern.js\";\n\nexport const addressScalar = defineCatalogScalar({\n example: \"eip155:0x0000000000000000000000000000000000000000\",\n name: \"Address\",\n typescriptType: \"`${string}:0x${string}`\",\n zodSource:\n \"z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))\",\n schema: z.custom<`${string}:0x${string}`>((val) =>\n matchesScalarPattern(/^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/, val),\n ),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { matchesScalarPattern } from \"../pattern.js\";\n\nexport const attachmentRefScalar = defineCatalogScalar({\n example:\n \"attachment://v1:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\",\n name: \"AttachmentRef\",\n typescriptType: \"`attachment://v${number}:${string}`\",\n zodSource:\n \"z.custom<`attachment://v${number}:${string}`>((val) => /^attachment:\\\\/\\\\/v\\\\d+:.+$/.test(val as string))\",\n schema: z.custom<`attachment://v${number}:${string}`>((val) =>\n matchesScalarPattern(/^attachment:\\/\\/v\\d+:.+$/, val),\n ),\n representation: \"string\",\n});\n","import type { z } from \"zod\";\nimport type { ScalarLiteralNode } from \"./scalar-literal.js\";\nimport type { ScalarCoercion } from \"./types.js\";\n\n/** Runs `schema` on every path; `readLiteral` turns an inline literal into its value first. */\nexport function validatingCoercion<TValue>(\n schema: z.ZodType<TValue>,\n readLiteral: (node: ScalarLiteralNode) => unknown,\n): ScalarCoercion<TValue> {\n const parse = (value: unknown): TValue => schema.parse(value);\n return {\n parseValue: parse,\n parseLiteral: (node) => parse(readLiteral(node)),\n serialize: parse,\n };\n}\n","import type { z } from \"zod\";\nimport { validatingCoercion } from \"../coercion.js\";\nimport {\n floatOnlyNumber,\n literalString,\n objectFields,\n} from \"../scalar-literal.js\";\n\n// The document-engineering scalar resolvers this catalog replaced parsed an\n// amount's number only from a float literal, so an integer literal such as 5\n// is refused even though the schema accepts 5. The host does not use this\n// coercion yet; it accepts 5.\nexport function floatAmountCoercion(schema: z.ZodType<number>) {\n return validatingCoercion(schema, (node) => floatOnlyNumber(node, \"value\"));\n}\n\nexport function stringAmountCoercion<TValue>(schema: z.ZodType<TValue>) {\n return validatingCoercion(schema, (node) => {\n const fields = objectFields(node);\n const value = literalString(fields.get(\"value\"), \"value\");\n if (!/^\\d+(\\.\\d+)?$/.test(value)) {\n throw new TypeError(\"value must be a numeric string.\");\n }\n return { unit: literalString(fields.get(\"unit\"), \"unit\"), value };\n });\n}\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { floatAmountCoercion } from \"./amounts.js\";\n\nconst schema = z.number();\n\nexport const amountTokensScalar = defineCatalogScalar({\n name: \"Amount_Tokens\",\n typescriptType: \"number\",\n zodSource: \"z.number()\",\n schema,\n representation: \"number\",\n coercion: floatAmountCoercion(schema),\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const ethereumAddressScalar = defineCatalogScalar({\n name: \"EthereumAddress\",\n typescriptType: \"string\",\n zodSource:\n \"z.string().regex(/^0x[a-fA-F0-9]{40}$/, { error: 'Invalid Ethereum address format' })\",\n schema: z.string().regex(/^0x[a-fA-F0-9]{40}$/, {\n error: \"Invalid Ethereum address format\",\n }),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const emailAddressScalar = defineCatalogScalar({\n name: \"EmailAddress\",\n typescriptType: \"string\",\n zodSource: \"z.email()\",\n schema: z.email(),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { floatAmountCoercion } from \"./amounts.js\";\n\nconst schema = z.number();\n\nexport const amountPercentageScalar = defineCatalogScalar({\n name: \"Amount_Percentage\",\n typescriptType: \"number\",\n zodSource: \"z.number()\",\n schema,\n representation: \"number\",\n coercion: floatAmountCoercion(schema),\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const dateScalar = defineCatalogScalar({\n example: \"2024-01-01T00:00:00.000Z\",\n name: \"Date\",\n typescriptType: \"string\",\n zodSource: \"z.iso.datetime()\",\n schema: z.iso.datetime(),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const urlScalar = defineCatalogScalar({\n example: \"https://example.com\",\n name: \"URL\",\n typescriptType: \"string\",\n zodSource: \"z.url()\",\n schema: z.url(),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { floatAmountCoercion } from \"./amounts.js\";\n\nconst schema = z.number();\n\nexport const amountMoneyScalar = defineCatalogScalar({\n name: \"Amount_Money\",\n typescriptType: \"number\",\n zodSource: \"z.number()\",\n schema,\n representation: \"number\",\n coercion: floatAmountCoercion(schema),\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const olabelScalar = defineCatalogScalar({\n name: \"OLabel\",\n typescriptType: \"string\",\n zodSource: \"z.string()\",\n schema: z.string(),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const currencyScalar = defineCatalogScalar({\n name: \"Currency\",\n typescriptType: \"string\",\n zodSource: \"z.string()\",\n schema: z.string(),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const phidScalar = defineCatalogScalar({\n name: \"PHID\",\n typescriptType: \"string\",\n zodSource: \"z.string()\",\n schema: z.string(),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const oidScalar = defineCatalogScalar({\n name: \"OID\",\n typescriptType: \"string\",\n zodSource: \"z.string()\",\n schema: z.string(),\n representation: \"string\",\n});\n","import { z } from \"zod\";\nimport { validatingCoercion } from \"../coercion.js\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport {\n floatOnlyNumber,\n literalString,\n objectFields,\n} from \"../scalar-literal.js\";\n\nconst schema = z.object({ unit: z.string(), value: z.number() });\n\nexport const amountFiatScalar = defineCatalogScalar({\n name: \"Amount_Fiat\",\n typescriptType: \"{ unit: string, value: number }\",\n zodSource: \"z.object({ unit: z.string(), value: z.number() })\",\n schema,\n representation: \"json-object\",\n coercion: validatingCoercion(schema, (node) => {\n const fields = objectFields(node);\n return {\n unit: literalString(fields.get(\"unit\"), \"unit\"),\n value: floatOnlyNumber(fields.get(\"value\"), \"value\"),\n };\n }),\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { stringAmountCoercion } from \"./amounts.js\";\n\nconst schema = z.object({ unit: z.string(), value: z.string() });\n\nexport const amountCurrencyScalar = defineCatalogScalar({\n name: \"Amount_Currency\",\n typescriptType: \"{ unit: string, value: string }\",\n zodSource: \"z.object({ unit: z.string(), value: z.string()})\",\n schema,\n representation: \"json-object\",\n coercion: stringAmountCoercion(schema),\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport { stringAmountCoercion } from \"./amounts.js\";\n\nconst schema = z.object({ unit: z.string(), value: z.string() });\n\nexport const amountCryptoScalar = defineCatalogScalar({\n name: \"Amount_Crypto\",\n typescriptType: \"{ unit: string, value: string }\",\n zodSource: \"z.object({ unit: z.string(), value: z.string() })\",\n schema,\n representation: \"json-object\",\n coercion: stringAmountCoercion(schema),\n});\n","import { z } from \"zod\";\nimport { validatingCoercion } from \"../coercion.js\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\nimport {\n floatOnlyNumber,\n literalString,\n objectFields,\n} from \"../scalar-literal.js\";\n\nconst schema = z.object({ unit: z.string().optional(), value: z.number() });\n\nexport const amountScalar = defineCatalogScalar({\n name: \"Amount\",\n typescriptType: \"{ unit?: string, value?: number }\",\n zodSource: \"z.object({ unit: z.string().optional(), value: z.number() })\",\n schema,\n representation: \"json-object\",\n coercion: validatingCoercion(schema, (node) => {\n const fields = objectFields(node);\n const unit = fields.get(\"unit\");\n return {\n unit: unit === undefined ? undefined : literalString(unit, \"unit\"),\n value: floatOnlyNumber(fields.get(\"value\"), \"value\"),\n };\n }),\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const uploadScalar = defineCatalogScalar({\n name: \"Upload\",\n typescriptType: \"File\",\n zodSource: \"z.any()\",\n schema: z.any(),\n representation: \"opaque\",\n coercion: {\n parseValue: (value) => value,\n parseLiteral: () => {\n throw new TypeError(\"Upload literals are not supported.\");\n },\n serialize: (value) => value,\n },\n});\n","import { z } from \"zod\";\nimport { defineCatalogScalar } from \"../define-catalog-scalar.js\";\n\nexport const jsonObjectScalar = defineCatalogScalar({\n name: \"JSONObject\",\n typescriptType: null,\n zodSource: null,\n schema: z.record(z.string(), z.unknown()),\n representation: \"json-object\",\n});\n","import { unknownScalar } from \"./declarations/unknown.js\";\nimport { dateTimeScalar } from \"./declarations/date-time.js\";\nimport { addressScalar } from \"./declarations/address.js\";\nimport { attachmentRefScalar } from \"./declarations/attachment-ref.js\";\nimport { amountTokensScalar } from \"./declarations/amount-tokens.js\";\nimport { ethereumAddressScalar } from \"./declarations/ethereum-address.js\";\nimport { emailAddressScalar } from \"./declarations/email-address.js\";\nimport { amountPercentageScalar } from \"./declarations/amount-percentage.js\";\nimport { dateScalar } from \"./declarations/date.js\";\nimport { urlScalar } from \"./declarations/url.js\";\nimport { amountMoneyScalar } from \"./declarations/amount-money.js\";\nimport { olabelScalar } from \"./declarations/olabel.js\";\nimport { currencyScalar } from \"./declarations/currency.js\";\nimport { phidScalar } from \"./declarations/phid.js\";\nimport { oidScalar } from \"./declarations/oid.js\";\nimport { amountFiatScalar } from \"./declarations/amount-fiat.js\";\nimport { amountCurrencyScalar } from \"./declarations/amount-currency.js\";\nimport { amountCryptoScalar } from \"./declarations/amount-crypto.js\";\nimport { amountScalar } from \"./declarations/amount.js\";\nimport { uploadScalar } from \"./declarations/upload.js\";\nimport { jsonObjectScalar } from \"./declarations/json-object.js\";\nimport type { DescribedScalarDefinition } from \"./types.js\";\n\nconst declarations = [\n unknownScalar,\n dateTimeScalar,\n addressScalar,\n attachmentRefScalar,\n amountTokensScalar,\n ethereumAddressScalar,\n emailAddressScalar,\n amountPercentageScalar,\n dateScalar,\n urlScalar,\n amountMoneyScalar,\n olabelScalar,\n currencyScalar,\n phidScalar,\n oidScalar,\n amountFiatScalar,\n amountCurrencyScalar,\n amountCryptoScalar,\n amountScalar,\n uploadScalar,\n jsonObjectScalar,\n] as const;\n\nexport type CatalogScalarDefinition = (typeof declarations)[number];\n\nexport const scalarCatalog: readonly DescribedScalarDefinition[] =\n Object.freeze([...declarations]);\n\nconst byName = new Map(\n scalarCatalog.map((definition) => [definition.name, definition]),\n);\n\nexport function getCatalogScalar(\n name: string,\n): DescribedScalarDefinition | undefined {\n return byName.get(name);\n}\n\ntype DocumentModelScalar = DescribedScalarDefinition & {\n readonly typescriptType: string;\n readonly zodSource: string;\n};\n\n// A model's SDL may use every catalog scalar codegen can type. JSONObject is\n// host-only, so it has neither a TypeScript type nor a zod source.\nexport const documentModelScalars: readonly DocumentModelScalar[] =\n Object.freeze(\n scalarCatalog.filter(\n (definition): definition is DocumentModelScalar =>\n definition.typescriptType !== null && definition.zodSource !== null,\n ),\n );\n","import type { StoredScalarDefinition } from \"@powerhousedao/shared/document-model\";\nimport type { ScalarDefinition } from \"./types.js\";\n\n/** The metadata a stored definition records for a `defineScalar` binding. */\nexport function storedScalarDefinition(\n definition: ScalarDefinition,\n): StoredScalarDefinition {\n return {\n kind: \"powerhouse.scalar\",\n formatVersion: 1,\n name: definition.name,\n representation: definition.representation ?? \"json\",\n description: definition.description ?? \"\",\n coercion: {\n source: definition.coercion === undefined ? \"derived\" : \"explicit\",\n },\n coercionProfile: \"catalog-v1\",\n };\n}\n"],"mappings":";;AAGA,MAAa,oBAAoB,OAAO,IAAI,8BAA8B;AAC1E,MAAa,4BAA4B;;AAkDzC,SAAgB,wBAAwB,OAAyB;CAC/D,OAAO,OAAO,UAAU,YACtB,UAAU,QACV,qBAAqB,QACnB,MAAM,qBACN,KAAA;AACN;AAEA,SAAgB,mBAAmB,OAA2C;CAC5E,OAAO,wBAAwB,KAAK,MAAA;AACtC;;;AC1DA,SAAgB,oBACd,OAI0C;CAC1C,OAAO,OAAO,OAAO;EACnB,GAAG;GACF,oBAAA;CACH,CAAoD;AACtD;;;ACKA,IAAa,6BAAb,cAAgD,UAAU;CACxD,YAAY,MAAc;EACxB,MACE,aAAa,KAAK,4FACpB;EACA,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,mBAAmB,MAAkC;CACnE,QAAQ,KAAK,MAAb;EACE,KAAK;EACL,KAAK,QACH,OAAO,KAAK;EACd,KAAK;EACL,KAAK,SACH,OAAO,OAAO,KAAK,KAAK;EAC1B,KAAK,W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rD;EACF,CAAC;CACH,CGiBE;CFvC0B,oBAAoB;EAC9C,MAAM;EACN,gBAAgB;EAChB,WAAW;EACX,QAAQ,EAAE,IAAI;EACd,gBAAgB;EAChB,UAAU;GACR,aAAa,UAAU;GACvB,oBAAoB;IAClB,MAAM,IAAI,UAAU,oCAAoC;GAC1D;GACA,YAAY,UAAU;EACxB;CACF,CE2BE;CDxC8B,oBAAoB;EAClD,MAAM;EACN,gBAAgB;EAChB,WAAW;EACX,QAAQ,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;EACxC,gBAAgB;CAClB,CCmCE;AACF;AAIA,MAAa,gBACX,OAAO,OAAO,CAAC,GAAG,YAAY,CAAC;AAEjC,MAAM,SAAS,IAAI,IACjB,cAAc,KAAK,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CACjE;AAEA,SAAgB,iBACd,MACuC;CACvC,OAAO,OAAO,IAAI,IAAI;AACxB;AASA,MAAa,uBACX,OAAO,OACL,cAAc,QACX,eACC,WAAW,mBAAmB,QAAQ,WAAW,cAAc,IACnE,CACF;;;;ACvEF,SAAgB,uBACd,YACwB;CACxB,OAAO;EACL,MAAM;EACN,eAAe;EACf,MAAM,WAAW;EACjB,gBAAgB,WAAW,kBAAkB;EAC7C,aAAa,WAAW,eAAe;EACvC,UAAU,EACR,QAAQ,WAAW,aAAa,KAAA,IAAY,YAAY,WAC1D;EACA,iBAAiB;CACnB;AACF"}
|
package/dist/tooling.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DefinitionCheckReport, DefinitionCheckSkipReason, DefinitionDiagnostic, DefinitionPath, DefinitionSource, DocumentModelDefinition, DocumentModelModule, DocumentModelPHState, Sha256Digest, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
1
|
+
import { DefinitionCheckProfile, DefinitionCheckReport, DefinitionCheckSkipReason, DefinitionDiagnostic, DefinitionPath, DefinitionSource, DocumentModelDefinition, DocumentModelModule, DocumentModelPHState, Sha256Digest, UpgradeManifest } from "@powerhousedao/shared/document-model";
|
|
2
2
|
//#region src/definition/kernel/diagnostics.d.ts
|
|
3
3
|
/** @experimental One line: code, severity and phase, location, message, expected, received, related and repair. */
|
|
4
4
|
export declare function formatDefinitionDiagnostic(diagnostic: DefinitionDiagnostic): string;
|
|
@@ -169,8 +169,9 @@ type UnregisteredDefinition = {
|
|
|
169
169
|
readonly specifier: `./${string}`;
|
|
170
170
|
};
|
|
171
171
|
/**
|
|
172
|
-
* What every registered check reads. A wider input
|
|
173
|
-
*
|
|
172
|
+
* @experimental What every registered check reads. A wider input, such as
|
|
173
|
+
* ph-cli's release evidence, lets a later layer register checks that need
|
|
174
|
+
* more, without changing the runner.
|
|
174
175
|
*/
|
|
175
176
|
type DefinitionCheckInput = {
|
|
176
177
|
readonly sourceSet: DefinitionSourceSet;
|
|
@@ -188,24 +189,86 @@ type LoadedDefinitionProject = DefinitionCheckInput & {
|
|
|
188
189
|
};
|
|
189
190
|
//#endregion
|
|
190
191
|
//#region src/definition/tooling/check/types.d.ts
|
|
191
|
-
/**
|
|
192
|
+
/**
|
|
193
|
+
* @experimental One named check over normalized artifacts, which ph-cli passes
|
|
194
|
+
* to `checkProjectDefinitions`. It reports normalized paths.
|
|
195
|
+
*/
|
|
192
196
|
type DefinitionCheck<TInput extends DefinitionCheckInput = DefinitionCheckInput> = {
|
|
193
197
|
readonly name: string;
|
|
194
198
|
readonly run: (input: TInput) => readonly DefinitionDiagnostic[] | Promise<readonly DefinitionDiagnostic[]>;
|
|
195
199
|
};
|
|
196
200
|
//#endregion
|
|
197
201
|
//#region src/definition/tooling/check/check-project-definitions.d.ts
|
|
202
|
+
/**
|
|
203
|
+
* @experimental The checks `ph model check` runs on document models. A later
|
|
204
|
+
* layer, such as ph-cli's release profile, adds its own with
|
|
205
|
+
* `[...documentModelChecks, ...theirs]`.
|
|
206
|
+
*/
|
|
207
|
+
export declare const documentModelChecks: readonly DefinitionCheck[];
|
|
198
208
|
/**
|
|
199
209
|
* @experimental Runs every check over a loaded project and builds the stored
|
|
200
210
|
* check report with the project's load diagnostics. `definitions` adds
|
|
201
|
-
* inventory entries a caller checked itself
|
|
202
|
-
* projects are
|
|
211
|
+
* inventory entries a caller checked itself; `profile` (default `edit`) names
|
|
212
|
+
* the check list the caller ran. Experimental while code-first projects are
|
|
213
|
+
* introduced.
|
|
203
214
|
*/
|
|
204
215
|
export declare function checkProjectDefinitions<TInput extends DefinitionCheckInput = DefinitionCheckInput>(project: LoadedDefinitionProject & TInput, options?: {
|
|
205
216
|
readonly checks?: readonly DefinitionCheck<TInput>[];
|
|
206
217
|
readonly definitions?: DefinitionCheckReport["definitions"];
|
|
218
|
+
readonly profile?: DefinitionCheckProfile;
|
|
207
219
|
}): Promise<DefinitionCheckReport>;
|
|
208
220
|
//#endregion
|
|
221
|
+
//#region src/definition/tooling/release/types.d.ts
|
|
222
|
+
/**
|
|
223
|
+
* One reason a host would not serve a model as declared. Plain data, so a
|
|
224
|
+
* host's validator result is passed in as is and tooling never imports a host.
|
|
225
|
+
*/
|
|
226
|
+
type HostValidationFindingData = {
|
|
227
|
+
readonly kind: "scalar-unbound";
|
|
228
|
+
readonly documentType: string;
|
|
229
|
+
readonly scalar: string;
|
|
230
|
+
} | {
|
|
231
|
+
readonly kind: "scalar-mismatch";
|
|
232
|
+
readonly documentType: string;
|
|
233
|
+
readonly scalar: string;
|
|
234
|
+
readonly packageName: string;
|
|
235
|
+
/** Canonical JSON of the stored scalar metadata. */
|
|
236
|
+
readonly declared: string;
|
|
237
|
+
readonly registered: string;
|
|
238
|
+
} | {
|
|
239
|
+
readonly kind: "definition-invalid" | "definition-mismatch";
|
|
240
|
+
readonly documentType: string;
|
|
241
|
+
/** The host's wire diagnostics, with paths into the module. */
|
|
242
|
+
readonly diagnostics: readonly DefinitionDiagnostic[];
|
|
243
|
+
};
|
|
244
|
+
/** @experimental A host validator's result, as ph-cli passes it to `releaseChecks`. */
|
|
245
|
+
type HostValidationEvidence = {
|
|
246
|
+
readonly completed: true;
|
|
247
|
+
readonly findings: readonly HostValidationFindingData[];
|
|
248
|
+
} | {
|
|
249
|
+
/** The host validator could not run over the package. */
|
|
250
|
+
readonly completed: false;
|
|
251
|
+
/** What stopped it, package relative. */
|
|
252
|
+
readonly reason: string;
|
|
253
|
+
readonly findings: readonly HostValidationFindingData[];
|
|
254
|
+
};
|
|
255
|
+
/** @experimental The evidence ph-cli gathers for the release profile. */
|
|
256
|
+
type ReleaseEvidence = {
|
|
257
|
+
readonly host: HostValidationEvidence;
|
|
258
|
+
};
|
|
259
|
+
/** @experimental The input `releaseChecks` read. */
|
|
260
|
+
type ReleaseCheckInput = DefinitionCheckInput & {
|
|
261
|
+
readonly release: ReleaseEvidence;
|
|
262
|
+
};
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/definition/tooling/release/release-checks.d.ts
|
|
265
|
+
/**
|
|
266
|
+
* @experimental The checks the release profile of `ph build --release` and
|
|
267
|
+
* `ph model check --release` adds to `documentModelChecks`. They read the
|
|
268
|
+
* release evidence a caller gathered.
|
|
269
|
+
*/
|
|
270
|
+
export declare const releaseChecks: readonly DefinitionCheck<ReleaseCheckInput>[];
|
|
271
|
+
//#endregion
|
|
209
272
|
//#region src/definition/tooling/report/status.d.ts
|
|
210
273
|
type DefinitionStatus = DefinitionCheckReport["status"];
|
|
211
274
|
//#endregion
|
|
@@ -316,6 +379,6 @@ export declare function loadProjectDefinitions(request: {
|
|
|
316
379
|
readonly importedFiles: (specifier: string) => readonly string[];
|
|
317
380
|
}): Promise<ProjectDefinitions>;
|
|
318
381
|
//#endregion
|
|
319
|
-
export type { DefinitionInspectionReport, DefinitionSourceLoadRequest, DefinitionSourceOrigin, DefinitionSourceResolution, DefinitionSourceSelectionRequest, DefinitionSourceSet, DocumentModelFamilyInspection, DocumentModelInspection, LoadedDefinition, LoadedDefinitionSet, NormalizedDocumentModelArtifact, NormalizedDocumentModelResult, ProjectDefinitions, TypeScriptSourceImportInterface };
|
|
382
|
+
export type { DefinitionCheck, DefinitionCheckInput, DefinitionInspectionReport, DefinitionSourceLoadRequest, DefinitionSourceOrigin, DefinitionSourceResolution, DefinitionSourceSelectionRequest, DefinitionSourceSet, DocumentModelFamilyInspection, DocumentModelInspection, HostValidationEvidence, LoadedDefinition, LoadedDefinitionSet, NormalizedDocumentModelArtifact, NormalizedDocumentModelResult, ProjectDefinitions, ReleaseCheckInput, ReleaseEvidence, TypeScriptSourceImportInterface };
|
|
320
383
|
export {};
|
|
321
384
|
//# sourceMappingURL=tooling.d.mts.map
|
package/dist/tooling.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tooling.d.mts","names":[],"sources":["../src/definition/kernel/diagnostics.ts","../src/definition/tooling/adapters/types.ts","../src/definition/tooling/adapters/code-first-document-model-source-adapter.ts","../src/definition/tooling/definition-source-types.ts","../src/definition/tooling/definition-source-loader.ts","../src/definition/tooling/definition-source-resolution.ts","../src/definition/tooling/adapters/producer.ts","../src/definition/tooling/report/types.ts","../src/definition/tooling/check/types.ts","../src/definition/tooling/check/check-project-definitions.ts","../src/definition/tooling/report/status.ts","../src/definition/tooling/inspect/types.ts","../src/definition/tooling/inspect/inspect-project-definitions.ts","../src/definition/tooling/project/project-definitions.ts"],"mappings":";;;wBAuQgB,2BACd,YAAY;;;;;;;KC3PF;WACD;WACA,QAAQ;WACR;WAEA;WAEA,YAAY;WAEZ,QAAQ;WAER,eAAe;;;KAId;WACD,oBAAoB;WAEpB,iBAAiB;WACjB,sBAAsB;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"tooling.d.mts","names":[],"sources":["../src/definition/kernel/diagnostics.ts","../src/definition/tooling/adapters/types.ts","../src/definition/tooling/adapters/code-first-document-model-source-adapter.ts","../src/definition/tooling/definition-source-types.ts","../src/definition/tooling/definition-source-loader.ts","../src/definition/tooling/definition-source-resolution.ts","../src/definition/tooling/adapters/producer.ts","../src/definition/tooling/report/types.ts","../src/definition/tooling/check/types.ts","../src/definition/tooling/check/check-project-definitions.ts","../src/definition/tooling/release/types.ts","../src/definition/tooling/release/release-checks.ts","../src/definition/tooling/report/status.ts","../src/definition/tooling/inspect/types.ts","../src/definition/tooling/inspect/inspect-project-definitions.ts","../src/definition/tooling/project/project-definitions.ts"],"mappings":";;;wBAuQgB,2BACd,YAAY;;;;;;;KC3PF;WACD;WACA,QAAQ;WACR;WAEA;WAEA,YAAY;WAEZ,QAAQ;WAER,eAAe;;;KAId;WACD,oBAAoB;WAEpB,iBAAiB;WACjB,sBAAsB;;;;;;;;;wBC+MjB,kCACd,gBACA,QAAQ,mBACP;;;;;;;KCnOS,sBAAsB;;KAGtB,yBAAyB;;;;;;UAOpB;EACf,aAAa;aACF;aACA;aACA,iBAAiB;aACjB,SAAS;MAChB,QAAQ,SAAS;EAErB,iBAAiB,kBAAkB,eAAe;;;KAIxC;WACD;WAEA;;;KAIC,8BAA8B;;;;;WAK/B,iBAAiB;WACjB,SAAS;;;KAIR;WACD;WACA,WAAW;WACX,sBAAsB;;WAElB;WAAqC;;WAErC;WACA,YAAY;;;KAKf,iBAAiB;WAClB,QAAQ;WAER,MAAM;WACN,OAAO;;;KAIN,sBAAsB;WACvB,yBAAyB,iBAAiB;WAC1C,2BAA2B,iBAClC;;;;;;;;;;;;qBCqfS;;EAQX,YAAY,UAAU;EAItB,QACE,SAAS,mCACR;EAIG,2BACJ,SAAS,8BACR,QAAQ;;;;;;;;EA6EL,oBACJ,SAAS;aACE;MAEV;aAEY;aACA,WAAW,SAAS;;aAGpB;aACA,sBAAsB;;EAuB/B,WAAW;;;;;;;;wBC7IH,2BACd,SAAS,mCACR;;;;;;;;KC7iBS,wBAAwB,MAAM,mBAAmB;KAEjD;WACD,oBAAoB;WACpB,sBAAsB;;WAEtB,aAAa,oBAAoB;;KAGhC;WACD,QAAQ;WACR;WACA,iBAAiB;WACjB,SAAS;;WAET;;WAEA,QAAQ;;WAER;;KAGC,sBACV,OAAO,4BACJ,sBAAsB,QAAQ;;;;KC7BvB;WACD;;WAEA;;WAEA;;;;;;;KAQC;WACD,WAAW;;WAEX,oBAAoB;WACpB,uBAAuB;;;KAItB,0BAA0B;WAC3B,aAAa;;WAEb,sBAAsB;;WAEtB,cAAc,oBAAoB;;;;;;;;KC5BjC,gBACV,eAAe,uBAAuB;WAE7B;WACA,MACP,OAAO,oBAEI,yBACT,iBAAiB;;;;;;;;;qBCYV,8BAA8B;;;;;;;;wBAsCrB,wBACpB,eAAe,uBAAuB,sBAEtC,SAAS,0BAA0B,QACnC;WACW,kBAAkB,gBAAgB;WAClC,cAAc;WACd,UAAU;IAEpB,QAAQ;;;;;;;KCnEC;WAEG;WACA;WACA;;WAGA;WACA;WACA;WACA;;WAEA;WACA;;WAGA;WACA;;WAEA,sBAAsB;;;KAIzB;WAEG;WACA,mBAAmB;;;WAInB;;WAEA;WACA,mBAAmB;;;KAItB;WAA6B,MAAM;;;KAGnC,oBAAoB;WACrB,SAAS;;;;;;;;;qBCvCP,wBAAwB,gBAAgB;;;KCEzC,mBAAmB;;;;;;;KCEnB;WACD;WACA,QAAQ;WACR;aACE;aACA;;WAEF;aACE;aACA;aACA;eACE;eACA;eACA;eACA;eACA;eACA;iBACE;iBACA;;;;WAIN;aACE;aACA;;WAEF;;;;;;;;KASC;WACD;WACA;WACA;WACA,QAAQ;WACR,eAAe;WACf,mBAAmB;;;;;;;KAQlB;WACD;WACA;WACA,QAAQ;WACR,WAAW;WACX,mBAAmB;WACnB,sBAAsB;;WAEtB,aAAa;;;KAIZ;WACD;WACA;;;;;;;;;;wBC+CK,0BACd,SAAS,yBACT;WAAoB,YAAY;IAC/B;;;;;;;;KCjGS,qBAAqB;;WAEtB;;;;;;;;;;;wBAyJW,uBAAuB;WAClC,QAAQ;WACR;WACA,iBAAiB;WACjB,SAAS;WACT,qBAAqB;WACrB,gBAAgB;IACvB,QAAQ"}
|
package/dist/tooling.mjs
CHANGED
|
@@ -375,6 +375,35 @@ var DefinitionError = class extends Error {
|
|
|
375
375
|
}
|
|
376
376
|
};
|
|
377
377
|
//#endregion
|
|
378
|
+
//#region src/definition/compiler/module-definition.ts
|
|
379
|
+
/**
|
|
380
|
+
* Why `definition` cannot serve the module it is attached to: another
|
|
381
|
+
* document type, or no specification for the module's version.
|
|
382
|
+
*/
|
|
383
|
+
function definitionModuleMismatch(definition, module, path) {
|
|
384
|
+
if (definition.model.documentType !== module.documentType) return {
|
|
385
|
+
code: "PH-DM-DECLARATION-INVALID",
|
|
386
|
+
path: [
|
|
387
|
+
...path,
|
|
388
|
+
"model",
|
|
389
|
+
"documentType"
|
|
390
|
+
],
|
|
391
|
+
message: "The structured definition and the stored model describe different document types.",
|
|
392
|
+
expected: module.documentType,
|
|
393
|
+
received: definition.model.documentType,
|
|
394
|
+
repair: "Materialize the module and its definition from the same declaration."
|
|
395
|
+
};
|
|
396
|
+
const { version } = module;
|
|
397
|
+
if (version !== void 0 && !definition.specifications.some((entry) => entry.version === version)) return {
|
|
398
|
+
code: "PH-DM-DECLARATION-INVALID",
|
|
399
|
+
path: [...path, "specifications"],
|
|
400
|
+
message: `The specification history carries no version ${version}, which is the version this module serves.`,
|
|
401
|
+
expected: `a specification for version ${version}`,
|
|
402
|
+
received: definition.specifications.map((entry) => String(entry.version)).join(", "),
|
|
403
|
+
repair: "Compose the versions with defineDocumentModelFamily so every module carries the complete history."
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
//#endregion
|
|
378
407
|
//#region src/scalars/types.ts
|
|
379
408
|
const SCALAR_DEFINITION = Symbol.for("powerhouse.scalar-definition");
|
|
380
409
|
/** The definition format version `value` is branded with, if it has a brand. */
|
|
@@ -2064,17 +2093,14 @@ function artifact(collector, value, source, path) {
|
|
|
2064
2093
|
collector.merge(shape);
|
|
2065
2094
|
if (!usable || documentType === void 0 || shape.length > 0 || typeof version !== "number") return;
|
|
2066
2095
|
const definition = module.definition;
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
"definition",
|
|
2076
|
-
"specifications"
|
|
2077
|
-
], `The specification history carries no version ${version}, which is the version this module serves.`, `a specification for version ${version}`, definition.specifications.map((entry) => String(entry.version)).join(", "), "Compose the versions with defineDocumentModelFamily so every module carries the complete history.");
|
|
2096
|
+
const mismatch = definitionModuleMismatch(definition, {
|
|
2097
|
+
documentType,
|
|
2098
|
+
version
|
|
2099
|
+
}, [...path, "definition"]);
|
|
2100
|
+
if (mismatch !== void 0) {
|
|
2101
|
+
collector.add(mismatch);
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2078
2104
|
return {
|
|
2079
2105
|
kind: "powerhouse.document-model-artifact",
|
|
2080
2106
|
source,
|
|
@@ -4141,7 +4167,7 @@ function compareArtifacts(left, right) {
|
|
|
4141
4167
|
function compareInventoryEntries(left, right) {
|
|
4142
4168
|
return compareCodeUnits(left.key, right.key) || (left.version ?? 0) - (right.version ?? 0) || compareCodeUnits(left.source.specifier, right.source.specifier) || compareCodeUnits(canonicalJson(left.source.exportPath ?? []), canonicalJson(right.source.exportPath ?? [])) || compareCodeUnits(left.kind, right.kind);
|
|
4143
4169
|
}
|
|
4144
|
-
/** Builds the stored check report.
|
|
4170
|
+
/** Builds the stored check report. */
|
|
4145
4171
|
function definitionCheckReport(input) {
|
|
4146
4172
|
const diagnostics = sortedUniqueDiagnostics(input.diagnostics);
|
|
4147
4173
|
const definitions = [...input.artifacts.map((artifact) => ({
|
|
@@ -4160,7 +4186,7 @@ function definitionCheckReport(input) {
|
|
|
4160
4186
|
const common = {
|
|
4161
4187
|
kind: "powerhouse.definition-check",
|
|
4162
4188
|
formatVersion: 1,
|
|
4163
|
-
profile:
|
|
4189
|
+
profile: input.profile,
|
|
4164
4190
|
sourceSet: input.sourceSet,
|
|
4165
4191
|
definitions,
|
|
4166
4192
|
diagnostics,
|
|
@@ -4182,8 +4208,9 @@ function definitionCheckReport(input) {
|
|
|
4182
4208
|
//#endregion
|
|
4183
4209
|
//#region src/definition/tooling/check/check-project-definitions.ts
|
|
4184
4210
|
/**
|
|
4185
|
-
* The checks `ph model check` runs on document models. A later
|
|
4186
|
-
*
|
|
4211
|
+
* @experimental The checks `ph model check` runs on document models. A later
|
|
4212
|
+
* layer, such as ph-cli's release profile, adds its own with
|
|
4213
|
+
* `[...documentModelChecks, ...theirs]`.
|
|
4187
4214
|
*/
|
|
4188
4215
|
const documentModelChecks = Object.freeze([
|
|
4189
4216
|
storedMaterializationCheck,
|
|
@@ -4209,14 +4236,16 @@ function relocated(diagnostic, relocations) {
|
|
|
4209
4236
|
/**
|
|
4210
4237
|
* @experimental Runs every check over a loaded project and builds the stored
|
|
4211
4238
|
* check report with the project's load diagnostics. `definitions` adds
|
|
4212
|
-
* inventory entries a caller checked itself
|
|
4213
|
-
* projects are
|
|
4239
|
+
* inventory entries a caller checked itself; `profile` (default `edit`) names
|
|
4240
|
+
* the check list the caller ran. Experimental while code-first projects are
|
|
4241
|
+
* introduced.
|
|
4214
4242
|
*/
|
|
4215
4243
|
async function checkProjectDefinitions(project, options = {}) {
|
|
4216
4244
|
const relocations = project.relocations ?? /* @__PURE__ */ new Map();
|
|
4217
4245
|
const diagnostics = [...project.diagnostics];
|
|
4218
4246
|
for (const check of options.checks ?? documentModelChecks) for (const diagnostic of await check.run(project)) diagnostics.push(relocated(diagnostic, relocations));
|
|
4219
4247
|
return definitionCheckReport({
|
|
4248
|
+
profile: options.profile ?? "edit",
|
|
4220
4249
|
sourceSet: project.sourceSet,
|
|
4221
4250
|
...project.skipReason !== void 0 && { skipReason: project.skipReason },
|
|
4222
4251
|
artifacts: project.artifacts,
|
|
@@ -4225,6 +4254,160 @@ async function checkProjectDefinitions(project, options = {}) {
|
|
|
4225
4254
|
});
|
|
4226
4255
|
}
|
|
4227
4256
|
//#endregion
|
|
4257
|
+
//#region src/definition/tooling/release/diagnostic-codes.ts
|
|
4258
|
+
const releaseDiagnostics = defineDiagnosticCatalog({
|
|
4259
|
+
"PH-REL-HOST-SCALAR-UNBOUND": {
|
|
4260
|
+
severity: "error",
|
|
4261
|
+
phase: "package",
|
|
4262
|
+
meaning: "A model declares a package scalar the package registers no binding for, so a host serves it without validation"
|
|
4263
|
+
},
|
|
4264
|
+
"PH-REL-HOST-SCALAR-MISMATCH": {
|
|
4265
|
+
severity: "error",
|
|
4266
|
+
phase: "package",
|
|
4267
|
+
meaning: "A model declares a package scalar whose stored metadata differs from the binding the package registers"
|
|
4268
|
+
},
|
|
4269
|
+
"PH-REL-HOST-DEFINITION-INVALID": {
|
|
4270
|
+
severity: "error",
|
|
4271
|
+
phase: "definition",
|
|
4272
|
+
meaning: "A module's definition fails the wire shape, so a host serves the model from its stored SDL"
|
|
4273
|
+
},
|
|
4274
|
+
"PH-REL-HOST-DEFINITION-MISMATCH": {
|
|
4275
|
+
severity: "error",
|
|
4276
|
+
phase: "definition",
|
|
4277
|
+
meaning: "A module's definition does not serve that module's document type or version, so a host serves the model from its stored SDL"
|
|
4278
|
+
},
|
|
4279
|
+
"PH-REL-HOST-VALIDATION-INCOMPLETE": {
|
|
4280
|
+
severity: "error",
|
|
4281
|
+
phase: "import",
|
|
4282
|
+
meaning: "Host validation did not run, so the release check cannot tell whether a host serves the package as declared"
|
|
4283
|
+
}
|
|
4284
|
+
}, toolingDiagnostics);
|
|
4285
|
+
//#endregion
|
|
4286
|
+
//#region src/definition/tooling/release/checks/host-validation.ts
|
|
4287
|
+
/**
|
|
4288
|
+
* Where an author edits what a finding names. A host finding names a document
|
|
4289
|
+
* type, not a version, so it points at every artifact of that type; a scalar
|
|
4290
|
+
* finding narrows that to the served specifications that declare the scalar.
|
|
4291
|
+
*/
|
|
4292
|
+
function findingSites(artifacts, finding) {
|
|
4293
|
+
const ofType = artifacts.filter(({ documentType }) => documentType === finding.documentType);
|
|
4294
|
+
if ("scalar" in finding) {
|
|
4295
|
+
const declaring = ofType.flatMap((artifact) => {
|
|
4296
|
+
const served = servedSpecification(artifact);
|
|
4297
|
+
const index = served?.specification.scalars.findIndex(({ name }) => name === finding.scalar) ?? -1;
|
|
4298
|
+
return served === void 0 || index === -1 ? [] : [{
|
|
4299
|
+
artifact,
|
|
4300
|
+
path: [
|
|
4301
|
+
"specifications",
|
|
4302
|
+
served.index,
|
|
4303
|
+
"scalars",
|
|
4304
|
+
index
|
|
4305
|
+
]
|
|
4306
|
+
}];
|
|
4307
|
+
});
|
|
4308
|
+
if (declaring.length > 0) return declaring;
|
|
4309
|
+
}
|
|
4310
|
+
return ofType.map((artifact) => ({
|
|
4311
|
+
artifact,
|
|
4312
|
+
path: []
|
|
4313
|
+
}));
|
|
4314
|
+
}
|
|
4315
|
+
/** The first site carries the diagnostic; the others are related locations. */
|
|
4316
|
+
function attribution(sites, finding, alsoHere) {
|
|
4317
|
+
if (sites.length === 0) return {
|
|
4318
|
+
path: [],
|
|
4319
|
+
related: []
|
|
4320
|
+
};
|
|
4321
|
+
const [first, ...others] = sites;
|
|
4322
|
+
return {
|
|
4323
|
+
source: first.artifact.source,
|
|
4324
|
+
path: first.path,
|
|
4325
|
+
related: others.map(({ artifact, path }) => ({
|
|
4326
|
+
source: artifact.source,
|
|
4327
|
+
path,
|
|
4328
|
+
message: alsoHere
|
|
4329
|
+
}))
|
|
4330
|
+
};
|
|
4331
|
+
}
|
|
4332
|
+
function hostFindingDiagnostic(artifacts, finding) {
|
|
4333
|
+
const { documentType } = finding;
|
|
4334
|
+
const sites = findingSites(artifacts, finding);
|
|
4335
|
+
switch (finding.kind) {
|
|
4336
|
+
case "scalar-unbound": {
|
|
4337
|
+
const { source, path, related } = attribution(sites, finding, `This version also declares ${finding.scalar}.`);
|
|
4338
|
+
return releaseDiagnostics.create({
|
|
4339
|
+
code: "PH-REL-HOST-SCALAR-UNBOUND",
|
|
4340
|
+
...source !== void 0 && { source },
|
|
4341
|
+
definition: {
|
|
4342
|
+
kind: "scalar",
|
|
4343
|
+
key: finding.scalar
|
|
4344
|
+
},
|
|
4345
|
+
path,
|
|
4346
|
+
message: `${documentType} declares package scalar ${finding.scalar}, but the package registers no binding for it, so a host serves ${finding.scalar} values without validating them.`,
|
|
4347
|
+
expected: `an export named ${finding.scalar} in the package's scalars entry`,
|
|
4348
|
+
received: "no binding",
|
|
4349
|
+
repair: `Export the defineScalar binding the model uses from scalars/index.ts under the name ${finding.scalar}.`,
|
|
4350
|
+
...related.length > 0 && { related }
|
|
4351
|
+
});
|
|
4352
|
+
}
|
|
4353
|
+
case "scalar-mismatch": {
|
|
4354
|
+
const { source, path, related } = attribution(sites, finding, `This version also declares ${finding.scalar}.`);
|
|
4355
|
+
return releaseDiagnostics.create({
|
|
4356
|
+
code: "PH-REL-HOST-SCALAR-MISMATCH",
|
|
4357
|
+
...source !== void 0 && { source },
|
|
4358
|
+
definition: {
|
|
4359
|
+
kind: "scalar",
|
|
4360
|
+
key: finding.scalar
|
|
4361
|
+
},
|
|
4362
|
+
path,
|
|
4363
|
+
message: `${documentType} declares package scalar ${finding.scalar} differently from the binding package ${finding.packageName} registers, and a host serves the registered binding.`,
|
|
4364
|
+
expected: finding.declared,
|
|
4365
|
+
received: finding.registered,
|
|
4366
|
+
repair: `Use the ${finding.scalar} binding that scalars/index.ts exports in the model, so the model and the package declare one ${finding.scalar}.`,
|
|
4367
|
+
...related.length > 0 && { related }
|
|
4368
|
+
});
|
|
4369
|
+
}
|
|
4370
|
+
case "definition-invalid":
|
|
4371
|
+
case "definition-mismatch": {
|
|
4372
|
+
const { source, path, related } = attribution(sites, finding, `This version of ${documentType} carries the same definition.`);
|
|
4373
|
+
const invalid = finding.kind === "definition-invalid";
|
|
4374
|
+
const repairs = [...new Set(finding.diagnostics.map((d) => d.repair))];
|
|
4375
|
+
return releaseDiagnostics.create({
|
|
4376
|
+
code: invalid ? "PH-REL-HOST-DEFINITION-INVALID" : "PH-REL-HOST-DEFINITION-MISMATCH",
|
|
4377
|
+
...source !== void 0 && { source },
|
|
4378
|
+
definition: sites.length === 0 ? {
|
|
4379
|
+
kind: "document-model",
|
|
4380
|
+
key: documentType
|
|
4381
|
+
} : documentModelRef(sites[0].artifact),
|
|
4382
|
+
path,
|
|
4383
|
+
message: invalid ? `A host serves ${documentType} from its stored SDL, because the module's definition fails the wire shape.` : `A host serves ${documentType} from its stored SDL, because the module's definition declares another document type or version.`,
|
|
4384
|
+
repair: repairs.length > 0 ? repairs.join(" ") : "Materialize the module and its definition from the same declaration, and export the module materialize returned.",
|
|
4385
|
+
related: [...related, ...finding.diagnostics.map(({ code, path, message }) => ({
|
|
4386
|
+
path,
|
|
4387
|
+
message: `${code}: ${message}`
|
|
4388
|
+
}))]
|
|
4389
|
+
});
|
|
4390
|
+
}
|
|
4391
|
+
}
|
|
4392
|
+
}
|
|
4393
|
+
//#endregion
|
|
4394
|
+
//#region src/definition/tooling/release/release-checks.ts
|
|
4395
|
+
/**
|
|
4396
|
+
* @experimental The checks the release profile of `ph build --release` and
|
|
4397
|
+
* `ph model check --release` adds to `documentModelChecks`. They read the
|
|
4398
|
+
* release evidence a caller gathered.
|
|
4399
|
+
*/
|
|
4400
|
+
const releaseChecks = Object.freeze([{
|
|
4401
|
+
name: "host-validation",
|
|
4402
|
+
run: ({ artifacts, release: { host } }) => [...host.completed ? [] : [releaseDiagnostics.create({
|
|
4403
|
+
code: "PH-REL-HOST-VALIDATION-INCOMPLETE",
|
|
4404
|
+
path: [],
|
|
4405
|
+
message: "Host validation did not run, so this check cannot tell whether a host serves the package's models as declared.",
|
|
4406
|
+
received: host.reason,
|
|
4407
|
+
repair: "Fix what stopped host validation, then run the release check again."
|
|
4408
|
+
})], ...host.findings.map((finding) => hostFindingDiagnostic(artifacts, finding))]
|
|
4409
|
+
}]);
|
|
4410
|
+
//#endregion
|
|
4228
4411
|
//#region src/definition/tooling/inspect/diagnostic-codes.ts
|
|
4229
4412
|
const inspectDiagnostics = defineDiagnosticCatalog({ "PH-INSPECT-SELECTION-UNKNOWN": {
|
|
4230
4413
|
severity: "error",
|
|
@@ -4355,7 +4538,8 @@ async function loadProjectScalars(request) {
|
|
|
4355
4538
|
};
|
|
4356
4539
|
}
|
|
4357
4540
|
//#endregion
|
|
4358
|
-
//#region src/
|
|
4541
|
+
//#region src/scalars/stored-definition.ts
|
|
4542
|
+
/** The metadata a stored definition records for a `defineScalar` binding. */
|
|
4359
4543
|
function storedScalarDefinition(definition) {
|
|
4360
4544
|
return {
|
|
4361
4545
|
kind: "powerhouse.scalar",
|
|
@@ -4367,6 +4551,8 @@ function storedScalarDefinition(definition) {
|
|
|
4367
4551
|
coercionProfile: "catalog-v1"
|
|
4368
4552
|
};
|
|
4369
4553
|
}
|
|
4554
|
+
//#endregion
|
|
4555
|
+
//#region src/definition/compiler/stored-scalar.ts
|
|
4370
4556
|
function scalarReferences(catalogScalars, packageScalars) {
|
|
4371
4557
|
const catalog = documentModelScalars.map(({ name }) => name).filter((name) => catalogScalars.has(name)).map((name) => ({
|
|
4372
4558
|
name,
|
|
@@ -5401,6 +5587,6 @@ async function loadProjectDefinitions(request) {
|
|
|
5401
5587
|
};
|
|
5402
5588
|
}
|
|
5403
5589
|
//#endregion
|
|
5404
|
-
export { DefinitionSourceLoader, adaptCodeFirstDocumentModelSource, checkProjectDefinitions, formatDefinitionDiagnostic, inspectProjectDefinitions, loadProjectDefinitions, resolveDefinitionSelection };
|
|
5590
|
+
export { DefinitionSourceLoader, adaptCodeFirstDocumentModelSource, checkProjectDefinitions, documentModelChecks, formatDefinitionDiagnostic, inspectProjectDefinitions, loadProjectDefinitions, releaseChecks, resolveDefinitionSelection };
|
|
5405
5591
|
|
|
5406
5592
|
//# sourceMappingURL=tooling.mjs.map
|