@rippling/pebble-sdui-web 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/catalogs/custom-apps/catalog.d.ts +2 -2
  2. package/dist/catalogs/custom-apps/component-events.d.ts +1 -0
  3. package/dist/catalogs/custom-apps/component-props.d.ts +93 -53
  4. package/dist/catalogs/custom-apps/components.d.ts +3 -2
  5. package/dist/catalogs/custom-apps/index.cjs +4 -3
  6. package/dist/catalogs/custom-apps/index.cjs.map +1 -1
  7. package/dist/catalogs/custom-apps/index.d.ts +3 -3
  8. package/dist/catalogs/custom-apps/index.js +330 -333
  9. package/dist/catalogs/custom-apps/index.js.map +1 -1
  10. package/dist/catalogs/hub_platform/catalog.d.ts +1 -1
  11. package/dist/catalogs/hub_platform/component-props.d.ts +14 -6
  12. package/dist/catalogs/hub_platform/index.cjs +1 -1
  13. package/dist/catalogs/hub_platform/index.cjs.map +1 -1
  14. package/dist/catalogs/hub_platform/index.d.ts +1 -1
  15. package/dist/catalogs/hub_platform/index.js +86 -137
  16. package/dist/catalogs/hub_platform/index.js.map +1 -1
  17. package/dist/core/catalog-validation.cjs +2 -0
  18. package/dist/core/catalog-validation.cjs.map +1 -0
  19. package/dist/core/catalog-validation.d.ts +21 -0
  20. package/dist/core/catalog-validation.js +245 -0
  21. package/dist/core/catalog-validation.js.map +1 -0
  22. package/dist/core/directives.cjs +2 -0
  23. package/dist/core/directives.cjs.map +1 -0
  24. package/dist/core/directives.d.ts +72 -0
  25. package/dist/core/directives.js +35 -0
  26. package/dist/core/directives.js.map +1 -0
  27. package/dist/core/expressions.d.ts +5 -15
  28. package/dist/core/index.cjs +1 -1
  29. package/dist/core/index.d.ts +2 -0
  30. package/dist/core/index.js +28 -20
  31. package/dist/core/index.js.map +1 -1
  32. package/dist/docs/typescript/web/catalogs/custom-apps/actions.md +3 -2
  33. package/dist/docs/typescript/web/catalogs/custom-apps/components.md +38 -7
  34. package/dist/docs/typescript/web/catalogs/custom-apps/readme.md +1 -1
  35. package/dist/docs/typescript/web/catalogs/custom-apps/types.md +64 -0
  36. package/dist/docs/typescript/web/catalogs/hub_platform/components.md +1 -1
  37. package/dist/docs/typescript/web/catalogs/hub_platform/types.md +14 -0
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.d.ts +2 -2
  40. package/dist/index.js +25 -17
  41. package/dist/index.js.map +1 -1
  42. package/dist/sdk-docs.cjs +208 -1
  43. package/dist/sdk-docs.cjs.map +1 -1
  44. package/dist/sdk-docs.js +213 -0
  45. package/dist/sdk-docs.js.map +1 -1
  46. package/package.json +1 -6
  47. package/dist/catalogs/ai_gateway/action-params.d.ts +0 -5
  48. package/dist/catalogs/ai_gateway/actions.d.ts +0 -5
  49. package/dist/catalogs/ai_gateway/catalog.d.ts +0 -33
  50. package/dist/catalogs/ai_gateway/component-events.d.ts +0 -6
  51. package/dist/catalogs/ai_gateway/component-props.d.ts +0 -51
  52. package/dist/catalogs/ai_gateway/components.d.ts +0 -7
  53. package/dist/catalogs/ai_gateway/function-params.d.ts +0 -5
  54. package/dist/catalogs/ai_gateway/functions.d.ts +0 -5
  55. package/dist/catalogs/ai_gateway/index.cjs +0 -2
  56. package/dist/catalogs/ai_gateway/index.cjs.map +0 -1
  57. package/dist/catalogs/ai_gateway/index.d.ts +0 -11
  58. package/dist/catalogs/ai_gateway/index.js +0 -366
  59. package/dist/catalogs/ai_gateway/index.js.map +0 -1
  60. package/dist/catalogs/ai_gateway/render.d.ts +0 -20
  61. package/dist/docs/typescript/web/catalogs/ai_gateway/actions.md +0 -6
  62. package/dist/docs/typescript/web/catalogs/ai_gateway/components.md +0 -31
  63. package/dist/docs/typescript/web/catalogs/ai_gateway/computed-functions.md +0 -6
  64. package/dist/docs/typescript/web/catalogs/ai_gateway/definitions.md +0 -6
  65. package/dist/docs/typescript/web/catalogs/ai_gateway/readme.md +0 -16
  66. package/dist/docs/typescript/web/catalogs/ai_gateway/types.md +0 -75
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-validation.cjs","sources":["../../../sdui-core/src/catalog-validation.ts"],"sourcesContent":["export type JsonSchema = Record<string, unknown> & {\n anyOf?: unknown[];\n properties?: Record<string, JsonSchema>;\n $defs?: Record<string, Record<string, unknown>>;\n};\n\ntype DirectiveDefinitions = Record<string, Record<string, unknown>>;\n\ninterface CatalogSchemaValidatorOptions {\n defs: Record<string, Record<string, unknown>>;\n directives?: DirectiveDefinitions;\n supportsStandardDirectives: boolean;\n validateSchema: (schema: Record<string, unknown>, value: unknown) => string[];\n}\n\nconst PROP_VALUE_REF_SCHEMAS: JsonSchema[] = [\n {\n type: 'object',\n additionalProperties: false,\n properties: { $state: { type: 'string' } },\n required: ['$state'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $bindState: { type: 'string' } },\n required: ['$bindState'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $item: { type: 'string' } },\n required: ['$item'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $bindItem: { type: 'string' } },\n required: ['$bindItem'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $index: {} },\n required: ['$index'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $template: { type: 'string' } },\n required: ['$template'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $cond: {}, $then: {}, $else: {} },\n required: ['$cond', '$then', '$else'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $computed: { type: 'string' }, args: { type: 'object' } },\n required: ['$computed', 'args'],\n },\n];\n\nconst STANDARD_DIRECTIVE_SCHEMAS: JsonSchema[] = [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $format: { enum: ['date', 'currency', 'number', 'percent'] },\n value: {},\n locale: { type: 'string' },\n currency: { type: 'string' },\n notation: { type: 'string' },\n style: { type: 'string' },\n options: { type: 'object' },\n now: { type: 'number' },\n },\n required: ['$format', 'value'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $math: {\n enum: ['add', 'subtract', 'multiply', 'divide', 'mod', 'min', 'max'],\n },\n a: {},\n b: {},\n },\n required: ['$math', 'a', 'b'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $math: { enum: ['round', 'floor', 'ceil', 'abs'] }, a: {} },\n required: ['$math', 'a'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $concat: { type: 'array' } },\n required: ['$concat'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $count: {} },\n required: ['$count'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $truncate: {},\n length: { type: 'number' },\n suffix: { type: 'string' },\n },\n required: ['$truncate'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $pluralize: {},\n zero: { type: 'string' },\n one: { type: 'string' },\n other: { type: 'string' },\n },\n required: ['$pluralize', 'one', 'other'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $join: {}, separator: { type: 'string' } },\n required: ['$join'],\n },\n];\n\nconst STANDARD_DIRECTIVE_NAMES = new Set([\n '$format',\n '$math',\n '$concat',\n '$count',\n '$truncate',\n '$pluralize',\n '$join',\n]);\n\nconst EXPRESSION_SCHEMA_DEF = '__pebbleExpression';\nconst EXPRESSION_SCHEMA_REF = { $ref: `#/$defs/${EXPRESSION_SCHEMA_DEF}` };\n\nfunction isSchema(value: unknown): value is JsonSchema {\n return Boolean(value && typeof value === 'object' && !Array.isArray(value));\n}\n\n/** Recursively replaces dynamic-input schema markers with expression unions. */\nfunction withExpressionRefs(schema: JsonSchema): JsonSchema {\n const transformed = Object.fromEntries(\n Object.entries(schema).map(([key, value]) => {\n if (\n key === 'properties' ||\n key === 'patternProperties' ||\n key === '$defs'\n ) {\n return [\n key,\n isSchema(value)\n ? Object.fromEntries(\n Object.entries(value).map(([name, child]) => [\n name,\n isSchema(child) ? withExpressionRefs(child) : child,\n ])\n )\n : value,\n ];\n }\n if (key === 'items' || key === 'additionalProperties') {\n return [key, isSchema(value) ? withExpressionRefs(value) : value];\n }\n if (key === 'allOf' || key === 'anyOf' || key === 'oneOf') {\n return [\n key,\n Array.isArray(value)\n ? value.map(child =>\n isSchema(child) ? withExpressionRefs(child) : child\n )\n : value,\n ];\n }\n return [key, value];\n })\n ) as JsonSchema;\n\n if (transformed['x-pebble-accepts-dynamic-value'] !== true) {\n return transformed;\n }\n delete transformed['x-pebble-accepts-dynamic-value'];\n return { anyOf: [transformed, EXPRESSION_SCHEMA_REF] };\n}\n\n/**\n * Creates the schema transformations and nested-directive validation used by a\n * generated catalog validator.\n */\nexport function createCatalogSchemaValidator({\n defs,\n directives = {},\n supportsStandardDirectives,\n validateSchema,\n}: CatalogSchemaValidatorOptions): {\n preparePropsSchema: (schema: JsonSchema) => JsonSchema;\n nestedDirectiveErrors: (value: unknown, path: string) => string[];\n} {\n const customDirectiveSchemas = (): JsonSchema[] =>\n Object.values(directives)\n .map(definition => definition.schema)\n .filter(isSchema)\n .map(withExpressionRefs);\n\n const expressionSchema = (): JsonSchema => ({\n anyOf: [\n ...PROP_VALUE_REF_SCHEMAS,\n ...(supportsStandardDirectives ? STANDARD_DIRECTIVE_SCHEMAS : []),\n ...customDirectiveSchemas(),\n ],\n });\n\n /** Makes catalog-owned shared definitions available to a validation schema. */\n const withCatalogDefs = (schema: JsonSchema): JsonSchema => ({\n ...schema,\n ...(Object.keys(defs).length > 0\n ? {\n $defs: {\n ...Object.fromEntries(\n Object.entries(defs).map(([name, definition]) => [\n name,\n withExpressionRefs(definition),\n ])\n ),\n ...(schema.$defs ?? {}),\n },\n }\n : {}),\n });\n\n /** Allows reactive expressions and directives in component prop schemas. */\n const preparePropsSchema = (schema: JsonSchema): JsonSchema => {\n const result = JSON.parse(JSON.stringify(schema)) as JsonSchema;\n const properties = result.properties ?? {};\n const hasCustomDirectives = Object.keys(directives).length > 0;\n const propValueAlternatives = [\n ...PROP_VALUE_REF_SCHEMAS,\n ...(supportsStandardDirectives ? STANDARD_DIRECTIVE_SCHEMAS : []),\n ...customDirectiveSchemas(),\n ];\n for (const propName of Object.keys(properties)) {\n const propSchema = properties[propName];\n if (Array.isArray(propSchema.anyOf)) {\n propSchema.anyOf = [...propSchema.anyOf, ...propValueAlternatives];\n } else {\n properties[propName] = {\n anyOf: [propSchema, ...propValueAlternatives],\n };\n }\n }\n if (hasCustomDirectives) {\n result.$defs = {\n ...(result.$defs ?? {}),\n [EXPRESSION_SCHEMA_DEF]: expressionSchema(),\n };\n }\n return withCatalogDefs(result);\n };\n\n const standardDirectiveSchemas = (value: JsonSchema): JsonSchema[] => {\n if (!supportsStandardDirectives) {\n return [];\n }\n const name = Object.keys(value).find(key =>\n STANDARD_DIRECTIVE_NAMES.has(key)\n );\n return name\n ? STANDARD_DIRECTIVE_SCHEMAS.filter(schema =>\n Object.prototype.hasOwnProperty.call(schema.properties, name)\n )\n : [];\n };\n\n /** Validates directives nested below a component's top-level prop value. */\n const visitNestedDirectives = (\n value: unknown,\n path: string,\n validateCurrent: boolean\n ): string[] => {\n if (Array.isArray(value)) {\n return value.flatMap((item, index) =>\n visitNestedDirectives(item, `${path}.${index}`, true)\n );\n }\n if (!isSchema(value)) {\n return [];\n }\n\n const errors: string[] = [];\n if (validateCurrent) {\n const standardSchemas = standardDirectiveSchemas(value);\n if (standardSchemas.length > 0) {\n errors.push(\n ...validateSchema({ anyOf: standardSchemas }, value).map(\n error => `nested directive ${path}: ${error}`\n )\n );\n }\n\n const customName = Object.keys(value).find(name => name in directives);\n const customSchema = customName\n ? directives[customName]?.schema\n : undefined;\n if (isSchema(customSchema)) {\n const prepared = withCatalogDefs(withExpressionRefs(customSchema));\n prepared.$defs = {\n ...(prepared.$defs ?? {}),\n [EXPRESSION_SCHEMA_DEF]: expressionSchema(),\n };\n errors.push(\n ...validateSchema(prepared, value).map(\n error => `nested directive ${path}: ${error}`\n )\n );\n }\n }\n\n for (const [key, nested] of Object.entries(value)) {\n errors.push(...visitNestedDirectives(nested, `${path}.${key}`, true));\n }\n return errors;\n };\n\n return {\n preparePropsSchema,\n nestedDirectiveErrors: (value, path) =>\n visitNestedDirectives(value, path, false),\n };\n}\n"],"names":["PROP_VALUE_REF_SCHEMAS","STANDARD_DIRECTIVE_SCHEMAS","STANDARD_DIRECTIVE_NAMES","EXPRESSION_SCHEMA_DEF","EXPRESSION_SCHEMA_REF","isSchema","value","withExpressionRefs","schema","transformed","key","name","child","createCatalogSchemaValidator","defs","directives","supportsStandardDirectives","validateSchema","customDirectiveSchemas","definition","expressionSchema","withCatalogDefs","preparePropsSchema","result","properties","hasCustomDirectives","propValueAlternatives","propName","propSchema","standardDirectiveSchemas","visitNestedDirectives","path","validateCurrent","item","index","errors","standardSchemas","error","customName","customSchema","_a","prepared","nested"],"mappings":"gFAeA,MAAMA,EAAuC,CAC3C,CACE,KAAM,SACN,qBAAsB,GACtB,WAAY,CAAE,OAAQ,CAAE,KAAM,SAAS,EACvC,SAAU,CAAC,QAAQ,CAAA,EAErB,CACE,KAAM,SACN,qBAAsB,GACtB,WAAY,CAAE,WAAY,CAAE,KAAM,SAAS,EAC3C,SAAU,CAAC,YAAY,CAAA,EAEzB,CACE,KAAM,SACN,qBAAsB,GACtB,WAAY,CAAE,MAAO,CAAE,KAAM,SAAS,EACtC,SAAU,CAAC,OAAO,CAAA,EAEpB,CACE,KAAM,SACN,qBAAsB,GACtB,WAAY,CAAE,UAAW,CAAE,KAAM,SAAS,EAC1C,SAAU,CAAC,WAAW,CAAA,EAExB,CACE,KAAM,SACN,qBAAsB,GACtB,WAAY,CAAE,OAAQ,EAAC,EACvB,SAAU,CAAC,QAAQ,CAAA,EAErB,CACE,KAAM,SACN,qBAAsB,GACtB,WAAY,CAAE,UAAW,CAAE,KAAM,SAAS,EAC1C,SAAU,CAAC,WAAW,CAAA,EAExB,CACE,KAAM,SACN,qBAAsB,GACtB,WAAY,CAAE,MAAO,CAAA,EAAI,MAAO,CAAA,EAAI,MAAO,EAAC,EAC5C,SAAU,CAAC,QAAS,QAAS,OAAO,CAAA,EAEt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S,oBAAoBN,CAAI,KAAKM,CAAK,EAAA,CAC7C,CAEJ,CACF,CAEA,SAAW,CAAC3B,EAAKgC,CAAM,IAAK,OAAO,QAAQpC,CAAK,EAC9C6B,EAAO,KAAK,GAAGL,EAAsBY,EAAQ,GAAGX,CAAI,IAAIrB,CAAG,GAAI,EAAI,CAAC,EAEtE,OAAOyB,CACT,EAEA,MAAO,CACL,mBAAAb,EACA,sBAAuB,CAAChB,EAAOyB,IAC7BD,EAAsBxB,EAAOyB,EAAM,EAAK,CAAA,CAE9C"}
@@ -0,0 +1,21 @@
1
+ export type JsonSchema = Record<string, unknown> & {
2
+ anyOf?: unknown[];
3
+ properties?: Record<string, JsonSchema>;
4
+ $defs?: Record<string, Record<string, unknown>>;
5
+ };
6
+ type DirectiveDefinitions = Record<string, Record<string, unknown>>;
7
+ interface CatalogSchemaValidatorOptions {
8
+ defs: Record<string, Record<string, unknown>>;
9
+ directives?: DirectiveDefinitions;
10
+ supportsStandardDirectives: boolean;
11
+ validateSchema: (schema: Record<string, unknown>, value: unknown) => string[];
12
+ }
13
+ /**
14
+ * Creates the schema transformations and nested-directive validation used by a
15
+ * generated catalog validator.
16
+ */
17
+ export declare function createCatalogSchemaValidator({ defs, directives, supportsStandardDirectives, validateSchema, }: CatalogSchemaValidatorOptions): {
18
+ preparePropsSchema: (schema: JsonSchema) => JsonSchema;
19
+ nestedDirectiveErrors: (value: unknown, path: string) => string[];
20
+ };
21
+ export {};
@@ -0,0 +1,245 @@
1
+ const P = [
2
+ {
3
+ type: "object",
4
+ additionalProperties: !1,
5
+ properties: { $state: { type: "string" } },
6
+ required: ["$state"]
7
+ },
8
+ {
9
+ type: "object",
10
+ additionalProperties: !1,
11
+ properties: { $bindState: { type: "string" } },
12
+ required: ["$bindState"]
13
+ },
14
+ {
15
+ type: "object",
16
+ additionalProperties: !1,
17
+ properties: { $item: { type: "string" } },
18
+ required: ["$item"]
19
+ },
20
+ {
21
+ type: "object",
22
+ additionalProperties: !1,
23
+ properties: { $bindItem: { type: "string" } },
24
+ required: ["$bindItem"]
25
+ },
26
+ {
27
+ type: "object",
28
+ additionalProperties: !1,
29
+ properties: { $index: {} },
30
+ required: ["$index"]
31
+ },
32
+ {
33
+ type: "object",
34
+ additionalProperties: !1,
35
+ properties: { $template: { type: "string" } },
36
+ required: ["$template"]
37
+ },
38
+ {
39
+ type: "object",
40
+ additionalProperties: !1,
41
+ properties: { $cond: {}, $then: {}, $else: {} },
42
+ required: ["$cond", "$then", "$else"]
43
+ },
44
+ {
45
+ type: "object",
46
+ additionalProperties: !1,
47
+ properties: { $computed: { type: "string" }, args: { type: "object" } },
48
+ required: ["$computed", "args"]
49
+ }
50
+ ], b = [
51
+ {
52
+ type: "object",
53
+ additionalProperties: !1,
54
+ properties: {
55
+ $format: { enum: ["date", "currency", "number", "percent"] },
56
+ value: {},
57
+ locale: { type: "string" },
58
+ currency: { type: "string" },
59
+ notation: { type: "string" },
60
+ style: { type: "string" },
61
+ options: { type: "object" },
62
+ now: { type: "number" }
63
+ },
64
+ required: ["$format", "value"]
65
+ },
66
+ {
67
+ type: "object",
68
+ additionalProperties: !1,
69
+ properties: {
70
+ $math: {
71
+ enum: ["add", "subtract", "multiply", "divide", "mod", "min", "max"]
72
+ },
73
+ a: {},
74
+ b: {}
75
+ },
76
+ required: ["$math", "a", "b"]
77
+ },
78
+ {
79
+ type: "object",
80
+ additionalProperties: !1,
81
+ properties: { $math: { enum: ["round", "floor", "ceil", "abs"] }, a: {} },
82
+ required: ["$math", "a"]
83
+ },
84
+ {
85
+ type: "object",
86
+ additionalProperties: !1,
87
+ properties: { $concat: { type: "array" } },
88
+ required: ["$concat"]
89
+ },
90
+ {
91
+ type: "object",
92
+ additionalProperties: !1,
93
+ properties: { $count: {} },
94
+ required: ["$count"]
95
+ },
96
+ {
97
+ type: "object",
98
+ additionalProperties: !1,
99
+ properties: {
100
+ $truncate: {},
101
+ length: { type: "number" },
102
+ suffix: { type: "string" }
103
+ },
104
+ required: ["$truncate"]
105
+ },
106
+ {
107
+ type: "object",
108
+ additionalProperties: !1,
109
+ properties: {
110
+ $pluralize: {},
111
+ zero: { type: "string" },
112
+ one: { type: "string" },
113
+ other: { type: "string" }
114
+ },
115
+ required: ["$pluralize", "one", "other"]
116
+ },
117
+ {
118
+ type: "object",
119
+ additionalProperties: !1,
120
+ properties: { $join: {}, separator: { type: "string" } },
121
+ required: ["$join"]
122
+ }
123
+ ], A = /* @__PURE__ */ new Set([
124
+ "$format",
125
+ "$math",
126
+ "$concat",
127
+ "$count",
128
+ "$truncate",
129
+ "$pluralize",
130
+ "$join"
131
+ ]), j = "__pebbleExpression", q = { $ref: `#/$defs/${j}` };
132
+ function f(a) {
133
+ return !!(a && typeof a == "object" && !Array.isArray(a));
134
+ }
135
+ function m(a) {
136
+ const n = Object.fromEntries(
137
+ Object.entries(a).map(([t, i]) => t === "properties" || t === "patternProperties" || t === "$defs" ? [
138
+ t,
139
+ f(i) ? Object.fromEntries(
140
+ Object.entries(i).map(([c, $]) => [
141
+ c,
142
+ f($) ? m($) : $
143
+ ])
144
+ ) : i
145
+ ] : t === "items" || t === "additionalProperties" ? [t, f(i) ? m(i) : i] : t === "allOf" || t === "anyOf" || t === "oneOf" ? [
146
+ t,
147
+ Array.isArray(i) ? i.map(
148
+ (c) => f(c) ? m(c) : c
149
+ ) : i
150
+ ] : [t, i])
151
+ );
152
+ return n["x-pebble-accepts-dynamic-value"] !== !0 ? n : (delete n["x-pebble-accepts-dynamic-value"], { anyOf: [n, q] });
153
+ }
154
+ function _({
155
+ defs: a,
156
+ directives: n = {},
157
+ supportsStandardDirectives: t,
158
+ validateSchema: i
159
+ }) {
160
+ const c = () => Object.values(n).map((e) => e.schema).filter(f).map(m), $ = () => ({
161
+ anyOf: [
162
+ ...P,
163
+ ...t ? b : [],
164
+ ...c()
165
+ ]
166
+ }), O = (e) => ({
167
+ ...e,
168
+ ...Object.keys(a).length > 0 ? {
169
+ $defs: {
170
+ ...Object.fromEntries(
171
+ Object.entries(a).map(([r, s]) => [
172
+ r,
173
+ m(s)
174
+ ])
175
+ ),
176
+ ...e.$defs ?? {}
177
+ }
178
+ } : {}
179
+ }), S = (e) => {
180
+ const r = JSON.parse(JSON.stringify(e)), s = r.properties ?? {}, y = Object.keys(n).length > 0, l = [
181
+ ...P,
182
+ ...t ? b : [],
183
+ ...c()
184
+ ];
185
+ for (const p of Object.keys(s)) {
186
+ const o = s[p];
187
+ Array.isArray(o.anyOf) ? o.anyOf = [...o.anyOf, ...l] : s[p] = {
188
+ anyOf: [o, ...l]
189
+ };
190
+ }
191
+ return y && (r.$defs = {
192
+ ...r.$defs ?? {},
193
+ [j]: $()
194
+ }), O(r);
195
+ }, h = (e) => {
196
+ if (!t)
197
+ return [];
198
+ const r = Object.keys(e).find(
199
+ (s) => A.has(s)
200
+ );
201
+ return r ? b.filter(
202
+ (s) => Object.prototype.hasOwnProperty.call(s.properties, r)
203
+ ) : [];
204
+ }, u = (e, r, s) => {
205
+ var l;
206
+ if (Array.isArray(e))
207
+ return e.flatMap(
208
+ (p, o) => u(p, `${r}.${o}`, !0)
209
+ );
210
+ if (!f(e))
211
+ return [];
212
+ const y = [];
213
+ if (s) {
214
+ const p = h(e);
215
+ p.length > 0 && y.push(
216
+ ...i({ anyOf: p }, e).map(
217
+ (d) => `nested directive ${r}: ${d}`
218
+ )
219
+ );
220
+ const o = Object.keys(e).find((d) => d in n), g = o ? (l = n[o]) == null ? void 0 : l.schema : void 0;
221
+ if (f(g)) {
222
+ const d = O(m(g));
223
+ d.$defs = {
224
+ ...d.$defs ?? {},
225
+ [j]: $()
226
+ }, y.push(
227
+ ...i(d, e).map(
228
+ (E) => `nested directive ${r}: ${E}`
229
+ )
230
+ );
231
+ }
232
+ }
233
+ for (const [p, o] of Object.entries(e))
234
+ y.push(...u(o, `${r}.${p}`, !0));
235
+ return y;
236
+ };
237
+ return {
238
+ preparePropsSchema: S,
239
+ nestedDirectiveErrors: (e, r) => u(e, r, !1)
240
+ };
241
+ }
242
+ export {
243
+ _ as createCatalogSchemaValidator
244
+ };
245
+ //# sourceMappingURL=catalog-validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-validation.js","sources":["../../../sdui-core/src/catalog-validation.ts"],"sourcesContent":["export type JsonSchema = Record<string, unknown> & {\n anyOf?: unknown[];\n properties?: Record<string, JsonSchema>;\n $defs?: Record<string, Record<string, unknown>>;\n};\n\ntype DirectiveDefinitions = Record<string, Record<string, unknown>>;\n\ninterface CatalogSchemaValidatorOptions {\n defs: Record<string, Record<string, unknown>>;\n directives?: DirectiveDefinitions;\n supportsStandardDirectives: boolean;\n validateSchema: (schema: Record<string, unknown>, value: unknown) => string[];\n}\n\nconst PROP_VALUE_REF_SCHEMAS: JsonSchema[] = [\n {\n type: 'object',\n additionalProperties: false,\n properties: { $state: { type: 'string' } },\n required: ['$state'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $bindState: { type: 'string' } },\n required: ['$bindState'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $item: { type: 'string' } },\n required: ['$item'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $bindItem: { type: 'string' } },\n required: ['$bindItem'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $index: {} },\n required: ['$index'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $template: { type: 'string' } },\n required: ['$template'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $cond: {}, $then: {}, $else: {} },\n required: ['$cond', '$then', '$else'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $computed: { type: 'string' }, args: { type: 'object' } },\n required: ['$computed', 'args'],\n },\n];\n\nconst STANDARD_DIRECTIVE_SCHEMAS: JsonSchema[] = [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $format: { enum: ['date', 'currency', 'number', 'percent'] },\n value: {},\n locale: { type: 'string' },\n currency: { type: 'string' },\n notation: { type: 'string' },\n style: { type: 'string' },\n options: { type: 'object' },\n now: { type: 'number' },\n },\n required: ['$format', 'value'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $math: {\n enum: ['add', 'subtract', 'multiply', 'divide', 'mod', 'min', 'max'],\n },\n a: {},\n b: {},\n },\n required: ['$math', 'a', 'b'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $math: { enum: ['round', 'floor', 'ceil', 'abs'] }, a: {} },\n required: ['$math', 'a'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $concat: { type: 'array' } },\n required: ['$concat'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $count: {} },\n required: ['$count'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $truncate: {},\n length: { type: 'number' },\n suffix: { type: 'string' },\n },\n required: ['$truncate'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n $pluralize: {},\n zero: { type: 'string' },\n one: { type: 'string' },\n other: { type: 'string' },\n },\n required: ['$pluralize', 'one', 'other'],\n },\n {\n type: 'object',\n additionalProperties: false,\n properties: { $join: {}, separator: { type: 'string' } },\n required: ['$join'],\n },\n];\n\nconst STANDARD_DIRECTIVE_NAMES = new Set([\n '$format',\n '$math',\n '$concat',\n '$count',\n '$truncate',\n '$pluralize',\n '$join',\n]);\n\nconst EXPRESSION_SCHEMA_DEF = '__pebbleExpression';\nconst EXPRESSION_SCHEMA_REF = { $ref: `#/$defs/${EXPRESSION_SCHEMA_DEF}` };\n\nfunction isSchema(value: unknown): value is JsonSchema {\n return Boolean(value && typeof value === 'object' && !Array.isArray(value));\n}\n\n/** Recursively replaces dynamic-input schema markers with expression unions. */\nfunction withExpressionRefs(schema: JsonSchema): JsonSchema {\n const transformed = Object.fromEntries(\n Object.entries(schema).map(([key, value]) => {\n if (\n key === 'properties' ||\n key === 'patternProperties' ||\n key === '$defs'\n ) {\n return [\n key,\n isSchema(value)\n ? Object.fromEntries(\n Object.entries(value).map(([name, child]) => [\n name,\n isSchema(child) ? withExpressionRefs(child) : child,\n ])\n )\n : value,\n ];\n }\n if (key === 'items' || key === 'additionalProperties') {\n return [key, isSchema(value) ? withExpressionRefs(value) : value];\n }\n if (key === 'allOf' || key === 'anyOf' || key === 'oneOf') {\n return [\n key,\n Array.isArray(value)\n ? value.map(child =>\n isSchema(child) ? withExpressionRefs(child) : child\n )\n : value,\n ];\n }\n return [key, value];\n })\n ) as JsonSchema;\n\n if (transformed['x-pebble-accepts-dynamic-value'] !== true) {\n return transformed;\n }\n delete transformed['x-pebble-accepts-dynamic-value'];\n return { anyOf: [transformed, EXPRESSION_SCHEMA_REF] };\n}\n\n/**\n * Creates the schema transformations and nested-directive validation used by a\n * generated catalog validator.\n */\nexport function createCatalogSchemaValidator({\n defs,\n directives = {},\n supportsStandardDirectives,\n validateSchema,\n}: CatalogSchemaValidatorOptions): {\n preparePropsSchema: (schema: JsonSchema) => JsonSchema;\n nestedDirectiveErrors: (value: unknown, path: string) => string[];\n} {\n const customDirectiveSchemas = (): JsonSchema[] =>\n Object.values(directives)\n .map(definition => definition.schema)\n .filter(isSchema)\n .map(withExpressionRefs);\n\n const expressionSchema = (): JsonSchema => ({\n anyOf: [\n ...PROP_VALUE_REF_SCHEMAS,\n ...(supportsStandardDirectives ? STANDARD_DIRECTIVE_SCHEMAS : []),\n ...customDirectiveSchemas(),\n ],\n });\n\n /** Makes catalog-owned shared definitions available to a validation schema. */\n const withCatalogDefs = (schema: JsonSchema): JsonSchema => ({\n ...schema,\n ...(Object.keys(defs).length > 0\n ? {\n $defs: {\n ...Object.fromEntries(\n Object.entries(defs).map(([name, definition]) => [\n name,\n withExpressionRefs(definition),\n ])\n ),\n ...(schema.$defs ?? {}),\n },\n }\n : {}),\n });\n\n /** Allows reactive expressions and directives in component prop schemas. */\n const preparePropsSchema = (schema: JsonSchema): JsonSchema => {\n const result = JSON.parse(JSON.stringify(schema)) as JsonSchema;\n const properties = result.properties ?? {};\n const hasCustomDirectives = Object.keys(directives).length > 0;\n const propValueAlternatives = [\n ...PROP_VALUE_REF_SCHEMAS,\n ...(supportsStandardDirectives ? STANDARD_DIRECTIVE_SCHEMAS : []),\n ...customDirectiveSchemas(),\n ];\n for (const propName of Object.keys(properties)) {\n const propSchema = properties[propName];\n if (Array.isArray(propSchema.anyOf)) {\n propSchema.anyOf = [...propSchema.anyOf, ...propValueAlternatives];\n } else {\n properties[propName] = {\n anyOf: [propSchema, ...propValueAlternatives],\n };\n }\n }\n if (hasCustomDirectives) {\n result.$defs = {\n ...(result.$defs ?? {}),\n [EXPRESSION_SCHEMA_DEF]: expressionSchema(),\n };\n }\n return withCatalogDefs(result);\n };\n\n const standardDirectiveSchemas = (value: JsonSchema): JsonSchema[] => {\n if (!supportsStandardDirectives) {\n return [];\n }\n const name = Object.keys(value).find(key =>\n STANDARD_DIRECTIVE_NAMES.has(key)\n );\n return name\n ? STANDARD_DIRECTIVE_SCHEMAS.filter(schema =>\n Object.prototype.hasOwnProperty.call(schema.properties, name)\n )\n : [];\n };\n\n /** Validates directives nested below a component's top-level prop value. */\n const visitNestedDirectives = (\n value: unknown,\n path: string,\n validateCurrent: boolean\n ): string[] => {\n if (Array.isArray(value)) {\n return value.flatMap((item, index) =>\n visitNestedDirectives(item, `${path}.${index}`, true)\n );\n }\n if (!isSchema(value)) {\n return [];\n }\n\n const errors: string[] = [];\n if (validateCurrent) {\n const standardSchemas = standardDirectiveSchemas(value);\n if (standardSchemas.length > 0) {\n errors.push(\n ...validateSchema({ anyOf: standardSchemas }, value).map(\n error => `nested directive ${path}: ${error}`\n )\n );\n }\n\n const customName = Object.keys(value).find(name => name in directives);\n const customSchema = customName\n ? directives[customName]?.schema\n : undefined;\n if (isSchema(customSchema)) {\n const prepared = withCatalogDefs(withExpressionRefs(customSchema));\n prepared.$defs = {\n ...(prepared.$defs ?? {}),\n [EXPRESSION_SCHEMA_DEF]: expressionSchema(),\n };\n errors.push(\n ...validateSchema(prepared, value).map(\n error => `nested directive ${path}: ${error}`\n )\n );\n }\n }\n\n for (const [key, nested] of Object.entries(value)) {\n errors.push(...visitNestedDirectives(nested, `${path}.${key}`, true));\n }\n return errors;\n };\n\n return {\n preparePropsSchema,\n nestedDirectiveErrors: (value, path) =>\n visitNestedDirectives(value, path, false),\n };\n}\n"],"names":["PROP_VALUE_REF_SCHEMAS","STANDARD_DIRECTIVE_SCHEMAS","STANDARD_DIRECTIVE_NAMES","EXPRESSION_SCHEMA_DEF","EXPRESSION_SCHEMA_REF","isSchema","value","withExpressionRefs","schema","transformed","key","name","child","createCatalogSchemaValidator","defs","directives","supportsStandardDirectives","validateSchema","customDirectiveSchemas","definition","expressionSchema","withCatalogDefs","preparePropsSchema","result","properties","hasCustomDirectives","propValueAlternatives","propName","propSchema","standardDirectiveSchemas","visitNestedDirectives","path","validateCurrent","_a","item","index","errors","standardSchemas","error","customName","customSchema","prepared","nested"],"mappings":"AAeA,MAAMA,IAAuC;AAAA,EAC3C;AAAA,IACE,MAAM;AAAA,IACN,sBAAsB;AAAA,IACtB,YAAY,EAAE,QAAQ,EAAE,MAAM,WAAS;AAAA,IACvC,UAAU,CAAC,QAAQ;AAAA,EAAA;AAAA,EAErB;AAAA,IACE,MAAM;AAAA,IACN,sBAAsB;AAAA,IACtB,YAAY,EAAE,YAAY,EAAE,MAAM,WAAS;AAAA,IAC3C,UAAU,CAAC,YAAY;AAAA,EAAA;AAAA,EAEzB;AAAA,IACE,MAAM;AAAA,IACN,sBAAsB;AAAA,IACtB,YAAY,EAAE,OAAO,EAAE,MAAM,WAAS;AAAA,IACtC,UAAU,CAAC,OAAO;AAAA,EAAA;AAAA,EAEpB;AAAA,IACE,MAAM;AAAA,IACN,sBAAsB;AAAA,IACtB,YAAY,EAAE,WAAW,EAAE,MAAM,WAAS;AAAA,IAC1C,UAAU,CAAC,WAAW;AAAA,EAAA;AAAA,EAExB;AAAA,IACE,MAAM;AAAA,IACN,sBAAsB;AAAA,IACtB,YAAY,EAAE,QAAQ,GAAC;AAAA,IACvB,UAAU,CAAC,QAAQ;AAAA,EAAA;AAAA,EAErB;AAA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AO;AAAA,UACL,GAAGnB,EAAewB,GAAUnC,CAAK,EAAE;AAAA,YACjC,CAAAgC,MAAS,oBAAoBP,CAAI,KAAKO,CAAK;AAAA,UAAA;AAAA,QAC7C;AAAA,MAEJ;AAAA,IACF;AAEA,eAAW,CAAC5B,GAAKgC,CAAM,KAAK,OAAO,QAAQpC,CAAK;AAC9C,MAAA8B,EAAO,KAAK,GAAGN,EAAsBY,GAAQ,GAAGX,CAAI,IAAIrB,CAAG,IAAI,EAAI,CAAC;AAEtE,WAAO0B;AAAA,EACT;AAEA,SAAO;AAAA,IACL,oBAAAd;AAAA,IACA,uBAAuB,CAAChB,GAAOyB,MAC7BD,EAAsBxB,GAAOyB,GAAM,EAAK;AAAA,EAAA;AAE9C;"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function u(t,n,r={}){return{$format:t,value:n,...r}}function o(t,n,r){return{$math:t,...n===void 0?{}:{a:n},...r===void 0?{}:{b:r}}}function c(...t){return{$concat:t}}function $(t){return{$count:t}}function e(t,n={}){return{$truncate:t,...n}}function i(t,n){return{$pluralize:t,...n}}function a(t,n={}){return{$join:t,...n}}exports.$concat=c;exports.$count=$;exports.$format=u;exports.$join=a;exports.$math=o;exports.$pluralize=i;exports.$truncate=e;
2
+ //# sourceMappingURL=directives.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directives.cjs","sources":["../../../sdui-core/src/directives.ts"],"sourcesContent":["/** Typed authoring helpers for the standard @json-render/directives package. */\n\nimport type {\n BindItemRef,\n BindStateRef,\n ComputedRef,\n CondRef,\n IndexRef,\n ItemRef,\n StateRef,\n TemplateRef,\n} from './expressions';\n\ndeclare const __directivePhantom: unique symbol;\n\n/** A json-render directive that resolves to T at runtime. */\nexport interface DirectiveRef<T> {\n readonly [__directivePhantom]: T;\n}\n\n/** A literal or runtime-resolved value accepted by directive inputs. */\nexport type DirectiveValue<T> =\n | T\n | StateRef<T>\n | BindStateRef<T>\n | ItemRef<T>\n | BindItemRef<T>\n | (T extends number ? IndexRef : never)\n | (T extends string ? TemplateRef : never)\n | CondRef<T>\n | ComputedRef<T>\n | DirectiveRef<T>;\n\n/** Values that the runtime can safely coerce to display text. */\nexport type StringifiableDirectiveValue =\n | DirectiveValue<string>\n | DirectiveValue<number>\n | DirectiveValue<boolean>\n | null;\n\n/** Values whose length can be resolved by `$count`. */\nexport type CountableDirectiveValue =\n | DirectiveValue<string>\n | DirectiveValue<readonly unknown[]>;\n\n/** Array values accepted by `$join`. */\nexport type ArrayDirectiveValue = DirectiveValue<readonly unknown[]>;\n\nexport type FormatKind = 'date' | 'currency' | 'number' | 'percent';\n\nexport interface FormatOptions {\n locale?: string;\n currency?: string;\n notation?: string;\n style?: string;\n options?: Record<string, unknown>;\n now?: number;\n}\n\nexport interface FormatRef extends DirectiveRef<string>, FormatOptions {\n readonly $format: FormatKind;\n readonly value: unknown;\n}\n\nexport function $format(\n kind: 'date',\n value: DirectiveValue<string> | DirectiveValue<number>,\n options?: FormatOptions\n): FormatRef;\nexport function $format(\n kind: Exclude<FormatKind, 'date'>,\n value: DirectiveValue<number>,\n options?: FormatOptions\n): FormatRef;\nexport function $format(\n kind: FormatKind,\n value: DirectiveValue<string> | DirectiveValue<number>,\n options: FormatOptions = {}\n): FormatRef {\n return { $format: kind, value, ...options } as FormatRef;\n}\n\nexport type MathOperation =\n | 'add'\n | 'subtract'\n | 'multiply'\n | 'divide'\n | 'mod'\n | 'min'\n | 'max'\n | 'round'\n | 'floor'\n | 'ceil'\n | 'abs';\n\nexport type BinaryMathOperation = Exclude<\n MathOperation,\n 'round' | 'floor' | 'ceil' | 'abs'\n>;\nexport type UnaryMathOperation = Extract<\n MathOperation,\n 'round' | 'floor' | 'ceil' | 'abs'\n>;\n\nexport interface MathRef extends DirectiveRef<number> {\n readonly $math: MathOperation;\n readonly a?: DirectiveValue<number>;\n readonly b?: DirectiveValue<number>;\n}\n\nexport function $math(\n operation: BinaryMathOperation,\n a: DirectiveValue<number>,\n b: DirectiveValue<number>\n): MathRef;\nexport function $math(\n operation: UnaryMathOperation,\n a: DirectiveValue<number>\n): MathRef;\nexport function $math(\n operation: MathOperation,\n a: DirectiveValue<number>,\n b?: DirectiveValue<number>\n): MathRef {\n return {\n $math: operation,\n ...(a === undefined ? {} : { a }),\n ...(b === undefined ? {} : { b }),\n } as MathRef;\n}\n\nexport interface ConcatRef extends DirectiveRef<string> {\n readonly $concat: readonly StringifiableDirectiveValue[];\n}\n\nexport function $concat(...values: StringifiableDirectiveValue[]): ConcatRef {\n return { $concat: values } as unknown as ConcatRef;\n}\n\nexport interface CountRef extends DirectiveRef<number> {\n readonly $count: CountableDirectiveValue;\n}\n\nexport function $count(value: CountableDirectiveValue): CountRef {\n return { $count: value } as CountRef;\n}\n\nexport interface TruncateOptions {\n length?: number;\n suffix?: string;\n}\n\nexport interface TruncateRef extends DirectiveRef<string>, TruncateOptions {\n readonly $truncate: StringifiableDirectiveValue;\n}\n\nexport function $truncate(\n value: StringifiableDirectiveValue,\n options: TruncateOptions = {}\n): TruncateRef {\n return { $truncate: value, ...options } as TruncateRef;\n}\n\nexport interface PluralizeOptions {\n one: string;\n other: string;\n zero?: string;\n}\n\nexport interface PluralizeRef extends DirectiveRef<string>, PluralizeOptions {\n readonly $pluralize: DirectiveValue<number>;\n}\n\nexport function $pluralize(\n value: DirectiveValue<number>,\n options: PluralizeOptions\n): PluralizeRef {\n return { $pluralize: value, ...options } as PluralizeRef;\n}\n\nexport interface JoinOptions {\n separator?: string;\n}\n\nexport interface JoinRef extends DirectiveRef<string>, JoinOptions {\n readonly $join: ArrayDirectiveValue;\n}\n\nexport function $join(\n value: ArrayDirectiveValue,\n options: JoinOptions = {}\n): JoinRef {\n return { $join: value, ...options } as JoinRef;\n}\n"],"names":["$format","kind","value","options","$math","operation","a","b","$concat","values","$count","$truncate","$pluralize","$join"],"mappings":"gFA0EO,SAASA,EACdC,EACAC,EACAC,EAAyB,CAAA,EACd,CACX,MAAO,CAAE,QAASF,EAAM,MAAAC,EAAO,GAAGC,CAAA,CACpC,CAuCO,SAASC,EACdC,EACAC,EACAC,EACS,CACT,MAAO,CACL,MAAOF,EACP,GAAIC,IAAM,OAAY,CAAA,EAAK,CAAE,EAAAA,CAAA,EAC7B,GAAIC,IAAM,OAAY,CAAA,EAAK,CAAE,EAAAA,CAAA,CAAE,CAEnC,CAMO,SAASC,KAAWC,EAAkD,CAC3E,MAAO,CAAE,QAASA,CAAA,CACpB,CAMO,SAASC,EAAOR,EAA0C,CAC/D,MAAO,CAAE,OAAQA,CAAA,CACnB,CAWO,SAASS,EACdT,EACAC,EAA2B,GACd,CACb,MAAO,CAAE,UAAWD,EAAO,GAAGC,CAAA,CAChC,CAYO,SAASS,EACdV,EACAC,EACc,CACd,MAAO,CAAE,WAAYD,EAAO,GAAGC,CAAA,CACjC,CAUO,SAASU,EACdX,EACAC,EAAuB,GACd,CACT,MAAO,CAAE,MAAOD,EAAO,GAAGC,CAAA,CAC5B"}
@@ -0,0 +1,72 @@
1
+ import { BindItemRef, BindStateRef, ComputedRef, CondRef, IndexRef, ItemRef, StateRef, TemplateRef } from './expressions';
2
+ declare const __directivePhantom: unique symbol;
3
+ /** A json-render directive that resolves to T at runtime. */
4
+ export interface DirectiveRef<T> {
5
+ readonly [__directivePhantom]: T;
6
+ }
7
+ /** A literal or runtime-resolved value accepted by directive inputs. */
8
+ export type DirectiveValue<T> = T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T> | (T extends number ? IndexRef : never) | (T extends string ? TemplateRef : never) | CondRef<T> | ComputedRef<T> | DirectiveRef<T>;
9
+ /** Values that the runtime can safely coerce to display text. */
10
+ export type StringifiableDirectiveValue = DirectiveValue<string> | DirectiveValue<number> | DirectiveValue<boolean> | null;
11
+ /** Values whose length can be resolved by `$count`. */
12
+ export type CountableDirectiveValue = DirectiveValue<string> | DirectiveValue<readonly unknown[]>;
13
+ /** Array values accepted by `$join`. */
14
+ export type ArrayDirectiveValue = DirectiveValue<readonly unknown[]>;
15
+ export type FormatKind = 'date' | 'currency' | 'number' | 'percent';
16
+ export interface FormatOptions {
17
+ locale?: string;
18
+ currency?: string;
19
+ notation?: string;
20
+ style?: string;
21
+ options?: Record<string, unknown>;
22
+ now?: number;
23
+ }
24
+ export interface FormatRef extends DirectiveRef<string>, FormatOptions {
25
+ readonly $format: FormatKind;
26
+ readonly value: unknown;
27
+ }
28
+ export declare function $format(kind: 'date', value: DirectiveValue<string> | DirectiveValue<number>, options?: FormatOptions): FormatRef;
29
+ export declare function $format(kind: Exclude<FormatKind, 'date'>, value: DirectiveValue<number>, options?: FormatOptions): FormatRef;
30
+ export type MathOperation = 'add' | 'subtract' | 'multiply' | 'divide' | 'mod' | 'min' | 'max' | 'round' | 'floor' | 'ceil' | 'abs';
31
+ export type BinaryMathOperation = Exclude<MathOperation, 'round' | 'floor' | 'ceil' | 'abs'>;
32
+ export type UnaryMathOperation = Extract<MathOperation, 'round' | 'floor' | 'ceil' | 'abs'>;
33
+ export interface MathRef extends DirectiveRef<number> {
34
+ readonly $math: MathOperation;
35
+ readonly a?: DirectiveValue<number>;
36
+ readonly b?: DirectiveValue<number>;
37
+ }
38
+ export declare function $math(operation: BinaryMathOperation, a: DirectiveValue<number>, b: DirectiveValue<number>): MathRef;
39
+ export declare function $math(operation: UnaryMathOperation, a: DirectiveValue<number>): MathRef;
40
+ export interface ConcatRef extends DirectiveRef<string> {
41
+ readonly $concat: readonly StringifiableDirectiveValue[];
42
+ }
43
+ export declare function $concat(...values: StringifiableDirectiveValue[]): ConcatRef;
44
+ export interface CountRef extends DirectiveRef<number> {
45
+ readonly $count: CountableDirectiveValue;
46
+ }
47
+ export declare function $count(value: CountableDirectiveValue): CountRef;
48
+ export interface TruncateOptions {
49
+ length?: number;
50
+ suffix?: string;
51
+ }
52
+ export interface TruncateRef extends DirectiveRef<string>, TruncateOptions {
53
+ readonly $truncate: StringifiableDirectiveValue;
54
+ }
55
+ export declare function $truncate(value: StringifiableDirectiveValue, options?: TruncateOptions): TruncateRef;
56
+ export interface PluralizeOptions {
57
+ one: string;
58
+ other: string;
59
+ zero?: string;
60
+ }
61
+ export interface PluralizeRef extends DirectiveRef<string>, PluralizeOptions {
62
+ readonly $pluralize: DirectiveValue<number>;
63
+ }
64
+ export declare function $pluralize(value: DirectiveValue<number>, options: PluralizeOptions): PluralizeRef;
65
+ export interface JoinOptions {
66
+ separator?: string;
67
+ }
68
+ export interface JoinRef extends DirectiveRef<string>, JoinOptions {
69
+ readonly $join: ArrayDirectiveValue;
70
+ }
71
+ export declare function $join(value: ArrayDirectiveValue, options?: JoinOptions): JoinRef;
72
+ export {};
@@ -0,0 +1,35 @@
1
+ function u(n, t, r = {}) {
2
+ return { $format: n, value: t, ...r };
3
+ }
4
+ function o(n, t, r) {
5
+ return {
6
+ $math: n,
7
+ ...t === void 0 ? {} : { a: t },
8
+ ...r === void 0 ? {} : { b: r }
9
+ };
10
+ }
11
+ function c(...n) {
12
+ return { $concat: n };
13
+ }
14
+ function $(n) {
15
+ return { $count: n };
16
+ }
17
+ function i(n, t = {}) {
18
+ return { $truncate: n, ...t };
19
+ }
20
+ function e(n, t) {
21
+ return { $pluralize: n, ...t };
22
+ }
23
+ function a(n, t = {}) {
24
+ return { $join: n, ...t };
25
+ }
26
+ export {
27
+ c as $concat,
28
+ $ as $count,
29
+ u as $format,
30
+ a as $join,
31
+ o as $math,
32
+ e as $pluralize,
33
+ i as $truncate
34
+ };
35
+ //# sourceMappingURL=directives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directives.js","sources":["../../../sdui-core/src/directives.ts"],"sourcesContent":["/** Typed authoring helpers for the standard @json-render/directives package. */\n\nimport type {\n BindItemRef,\n BindStateRef,\n ComputedRef,\n CondRef,\n IndexRef,\n ItemRef,\n StateRef,\n TemplateRef,\n} from './expressions';\n\ndeclare const __directivePhantom: unique symbol;\n\n/** A json-render directive that resolves to T at runtime. */\nexport interface DirectiveRef<T> {\n readonly [__directivePhantom]: T;\n}\n\n/** A literal or runtime-resolved value accepted by directive inputs. */\nexport type DirectiveValue<T> =\n | T\n | StateRef<T>\n | BindStateRef<T>\n | ItemRef<T>\n | BindItemRef<T>\n | (T extends number ? IndexRef : never)\n | (T extends string ? TemplateRef : never)\n | CondRef<T>\n | ComputedRef<T>\n | DirectiveRef<T>;\n\n/** Values that the runtime can safely coerce to display text. */\nexport type StringifiableDirectiveValue =\n | DirectiveValue<string>\n | DirectiveValue<number>\n | DirectiveValue<boolean>\n | null;\n\n/** Values whose length can be resolved by `$count`. */\nexport type CountableDirectiveValue =\n | DirectiveValue<string>\n | DirectiveValue<readonly unknown[]>;\n\n/** Array values accepted by `$join`. */\nexport type ArrayDirectiveValue = DirectiveValue<readonly unknown[]>;\n\nexport type FormatKind = 'date' | 'currency' | 'number' | 'percent';\n\nexport interface FormatOptions {\n locale?: string;\n currency?: string;\n notation?: string;\n style?: string;\n options?: Record<string, unknown>;\n now?: number;\n}\n\nexport interface FormatRef extends DirectiveRef<string>, FormatOptions {\n readonly $format: FormatKind;\n readonly value: unknown;\n}\n\nexport function $format(\n kind: 'date',\n value: DirectiveValue<string> | DirectiveValue<number>,\n options?: FormatOptions\n): FormatRef;\nexport function $format(\n kind: Exclude<FormatKind, 'date'>,\n value: DirectiveValue<number>,\n options?: FormatOptions\n): FormatRef;\nexport function $format(\n kind: FormatKind,\n value: DirectiveValue<string> | DirectiveValue<number>,\n options: FormatOptions = {}\n): FormatRef {\n return { $format: kind, value, ...options } as FormatRef;\n}\n\nexport type MathOperation =\n | 'add'\n | 'subtract'\n | 'multiply'\n | 'divide'\n | 'mod'\n | 'min'\n | 'max'\n | 'round'\n | 'floor'\n | 'ceil'\n | 'abs';\n\nexport type BinaryMathOperation = Exclude<\n MathOperation,\n 'round' | 'floor' | 'ceil' | 'abs'\n>;\nexport type UnaryMathOperation = Extract<\n MathOperation,\n 'round' | 'floor' | 'ceil' | 'abs'\n>;\n\nexport interface MathRef extends DirectiveRef<number> {\n readonly $math: MathOperation;\n readonly a?: DirectiveValue<number>;\n readonly b?: DirectiveValue<number>;\n}\n\nexport function $math(\n operation: BinaryMathOperation,\n a: DirectiveValue<number>,\n b: DirectiveValue<number>\n): MathRef;\nexport function $math(\n operation: UnaryMathOperation,\n a: DirectiveValue<number>\n): MathRef;\nexport function $math(\n operation: MathOperation,\n a: DirectiveValue<number>,\n b?: DirectiveValue<number>\n): MathRef {\n return {\n $math: operation,\n ...(a === undefined ? {} : { a }),\n ...(b === undefined ? {} : { b }),\n } as MathRef;\n}\n\nexport interface ConcatRef extends DirectiveRef<string> {\n readonly $concat: readonly StringifiableDirectiveValue[];\n}\n\nexport function $concat(...values: StringifiableDirectiveValue[]): ConcatRef {\n return { $concat: values } as unknown as ConcatRef;\n}\n\nexport interface CountRef extends DirectiveRef<number> {\n readonly $count: CountableDirectiveValue;\n}\n\nexport function $count(value: CountableDirectiveValue): CountRef {\n return { $count: value } as CountRef;\n}\n\nexport interface TruncateOptions {\n length?: number;\n suffix?: string;\n}\n\nexport interface TruncateRef extends DirectiveRef<string>, TruncateOptions {\n readonly $truncate: StringifiableDirectiveValue;\n}\n\nexport function $truncate(\n value: StringifiableDirectiveValue,\n options: TruncateOptions = {}\n): TruncateRef {\n return { $truncate: value, ...options } as TruncateRef;\n}\n\nexport interface PluralizeOptions {\n one: string;\n other: string;\n zero?: string;\n}\n\nexport interface PluralizeRef extends DirectiveRef<string>, PluralizeOptions {\n readonly $pluralize: DirectiveValue<number>;\n}\n\nexport function $pluralize(\n value: DirectiveValue<number>,\n options: PluralizeOptions\n): PluralizeRef {\n return { $pluralize: value, ...options } as PluralizeRef;\n}\n\nexport interface JoinOptions {\n separator?: string;\n}\n\nexport interface JoinRef extends DirectiveRef<string>, JoinOptions {\n readonly $join: ArrayDirectiveValue;\n}\n\nexport function $join(\n value: ArrayDirectiveValue,\n options: JoinOptions = {}\n): JoinRef {\n return { $join: value, ...options } as JoinRef;\n}\n"],"names":["$format","kind","value","options","$math","operation","a","b","$concat","values","$count","$truncate","$pluralize","$join"],"mappings":"AA0EO,SAASA,EACdC,GACAC,GACAC,IAAyB,CAAA,GACd;AACX,SAAO,EAAE,SAASF,GAAM,OAAAC,GAAO,GAAGC,EAAA;AACpC;AAuCO,SAASC,EACdC,GACAC,GACAC,GACS;AACT,SAAO;AAAA,IACL,OAAOF;AAAA,IACP,GAAIC,MAAM,SAAY,CAAA,IAAK,EAAE,GAAAA,EAAA;AAAA,IAC7B,GAAIC,MAAM,SAAY,CAAA,IAAK,EAAE,GAAAA,EAAA;AAAA,EAAE;AAEnC;AAMO,SAASC,KAAWC,GAAkD;AAC3E,SAAO,EAAE,SAASA,EAAA;AACpB;AAMO,SAASC,EAAOR,GAA0C;AAC/D,SAAO,EAAE,QAAQA,EAAA;AACnB;AAWO,SAASS,EACdT,GACAC,IAA2B,IACd;AACb,SAAO,EAAE,WAAWD,GAAO,GAAGC,EAAA;AAChC;AAYO,SAASS,EACdV,GACAC,GACc;AACd,SAAO,EAAE,YAAYD,GAAO,GAAGC,EAAA;AACjC;AAUO,SAASU,EACdX,GACAC,IAAuB,IACd;AACT,SAAO,EAAE,OAAOD,GAAO,GAAGC,EAAA;AAC5B;"}
@@ -1,14 +1,4 @@
1
- /**
2
- * Phantom-Typed Expression Markers
3
- *
4
- * Each expression helper returns a marker object that carries the resolved
5
- * value type as a phantom type. Builders accept PropValue<T> which
6
- * structurally matches only when the phantom type aligns with the prop type.
7
- *
8
- * The __phantom symbol is used to embed type information in runtime objects
9
- * without affecting JSON serialization. This enables compile-time type safety
10
- * while keeping the runtime representation clean.
11
- */
1
+ import { DirectiveRef } from './directives';
12
2
  declare const __phantom: unique symbol;
13
3
  /** Read-only reference to a state path. Carries resolved value type T. */
14
4
  export interface StateRef<T> {
@@ -48,8 +38,8 @@ export type TemplateInterpolation = StateRef<unknown> | ItemRef<unknown> | Index
48
38
  /** Conditional expression with typed branches. Uses T directly to avoid circular PropValue recursion. */
49
39
  export interface CondRef<T> {
50
40
  readonly $cond: unknown;
51
- readonly $then: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T>;
52
- readonly $else: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T>;
41
+ readonly $then: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T> | DirectiveRef<T>;
42
+ readonly $else: T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T> | DirectiveRef<T>;
53
43
  readonly [__phantom]: T;
54
44
  }
55
45
  /** Computed function expression. Carries resolved value type T. */
@@ -62,12 +52,12 @@ export interface ComputedRef<T> {
62
52
  * A prop value that is either a literal T or a phantom-typed expression
63
53
  * that resolves to T at runtime.
64
54
  */
65
- export type PropValue<T> = T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T> | (T extends number ? IndexRef : never) | (T extends string ? TemplateRef : never) | CondRef<T> | ComputedRef<T>;
55
+ export type PropValue<T> = T | StateRef<T> | BindStateRef<T> | ItemRef<T> | BindItemRef<T> | (T extends number ? IndexRef : never) | (T extends string ? TemplateRef : never) | CondRef<T> | ComputedRef<T> | DirectiveRef<T>;
66
56
  /**
67
57
  * A value in an action param: literal T or a read-only expression.
68
58
  * Narrower than PropValue — no bind refs, templates, or cond.
69
59
  */
70
- export type ActionParamValue<T> = T | StateRef<T> | ItemRef<T> | (T extends number ? IndexRef : never) | ComputedRef<T>;
60
+ export type ActionParamValue<T> = T | StateRef<T> | ItemRef<T> | (T extends number ? IndexRef : never) | ComputedRef<T> | DirectiveRef<T>;
71
61
  /**
72
62
  * Takes a plain props type and wraps each field with PropValue<T>.
73
63
  * Preserves optionality: required fields stay required, optional stay optional.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./spec.cjs"),r=require("./component-utils.cjs"),n=require("./action-utils.cjs"),e=require("./conditions.cjs");exports.createSpec=t.createSpec;exports.renderElementTree=t.renderElementTree;exports.buildNode=r.buildNode;exports.buildAction=n.buildAction;exports.$and=e.$and;exports.$or=e.$or;exports.$when=e.$when;exports.and_=e.$and;exports.equals=e.equals;exports.falsy=e.falsy;exports.gt=e.gt;exports.gte=e.gte;exports.lt=e.lt;exports.lte=e.lte;exports.neq=e.neq;exports.not_=e.not_;exports.or_=e.$or;exports.truthy=e.truthy;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./spec.cjs"),o=require("./component-utils.cjs"),n=require("./action-utils.cjs"),t=require("./directives.cjs"),e=require("./conditions.cjs");exports.createSpec=r.createSpec;exports.renderElementTree=r.renderElementTree;exports.buildNode=o.buildNode;exports.buildAction=n.buildAction;exports.$concat=t.$concat;exports.$count=t.$count;exports.$format=t.$format;exports.$join=t.$join;exports.$math=t.$math;exports.$pluralize=t.$pluralize;exports.$truncate=t.$truncate;exports.$and=e.$and;exports.$or=e.$or;exports.$when=e.$when;exports.and_=e.$and;exports.equals=e.equals;exports.falsy=e.falsy;exports.gt=e.gt;exports.gte=e.gte;exports.lt=e.lt;exports.lte=e.lte;exports.neq=e.neq;exports.not_=e.not_;exports.or_=e.$or;exports.truthy=e.truthy;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -8,6 +8,8 @@ export type { ComponentInputs, ComponentInputsOptionalProps, EventAction, Intern
8
8
  export { buildAction } from './action-utils';
9
9
  export type { ActionBinding, ActionConfirm, ActionOptions, ActionOnSuccess, ActionOnError, } from './action-utils';
10
10
  export type { PropValue, WrapWithPropValue, StateRef, BindStateRef, ItemRef, BindItemRef, IndexRef, TemplateRef, CondRef, ComputedRef, TemplateInterpolation, ActionParamValue, WrapWithActionParamValue, } from './expressions';
11
+ export { $format, $math, $concat, $count, $truncate, $pluralize, $join, } from './directives';
12
+ export type { DirectiveRef, FormatKind, FormatOptions, MathOperation, BinaryMathOperation, UnaryMathOperation, TruncateOptions, PluralizeOptions, JoinOptions, } from './directives';
11
13
  export { $when, equals, neq, gt, gte, lt, lte, truthy, falsy, not_, $and, $or, and_, or_, } from './conditions';
12
14
  export type { VisibilityBinding, ComparisonOps } from './conditions';
13
15
  export type { StatePaths, ValueAt, ArrayPaths, ArrayItemAt, ItemPaths, ItemValueAt, } from './paths';
@@ -1,25 +1,33 @@
1
- import { createSpec as o, renderElementTree as t } from "./spec.js";
2
- import { buildNode as a } from "./component-utils.js";
1
+ import { createSpec as t, renderElementTree as o } from "./spec.js";
2
+ import { buildNode as n } from "./component-utils.js";
3
3
  import { buildAction as l } from "./action-utils.js";
4
- import { $and as m, $or as p, $when as $, $and as s, equals as u, falsy as x, gt as c, gte as i, lt as _, lte as b, neq as g, not_ as h, $or as q, truthy as y } from "./conditions.js";
4
+ import { $concat as c, $count as d, $format as f, $join as p, $math as u, $pluralize as i, $truncate as x } from "./directives.js";
5
+ import { $and as h, $or as _, $when as b, $and as g, equals as q, falsy as y, gt as j, gte as w, lt as z, lte as A, neq as E, not_ as N, $or as S, truthy as T } from "./conditions.js";
5
6
  export {
6
- m as $and,
7
- p as $or,
8
- $ as $when,
9
- s as and_,
7
+ h as $and,
8
+ c as $concat,
9
+ d as $count,
10
+ f as $format,
11
+ p as $join,
12
+ u as $math,
13
+ _ as $or,
14
+ i as $pluralize,
15
+ x as $truncate,
16
+ b as $when,
17
+ g as and_,
10
18
  l as buildAction,
11
- a as buildNode,
12
- o as createSpec,
13
- u as equals,
14
- x as falsy,
15
- c as gt,
16
- i as gte,
17
- _ as lt,
18
- b as lte,
19
- g as neq,
20
- h as not_,
21
- q as or_,
22
- t as renderElementTree,
23
- y as truthy
19
+ n as buildNode,
20
+ t as createSpec,
21
+ q as equals,
22
+ y as falsy,
23
+ j as gt,
24
+ w as gte,
25
+ z as lt,
26
+ A as lte,
27
+ E as neq,
28
+ N as not_,
29
+ S as or_,
30
+ o as renderElementTree,
31
+ T as truthy
24
32
  };
25
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -161,9 +161,10 @@ on: {
161
161
 
162
162
  ## triggerFunction
163
163
 
164
- Call a Rippling Function. params.inputs is sent as event.parameters. Legacy top-level action and extra params are still supported.
164
+ Call a Rippling Function. params.inputs is sent as event.parameters.
165
165
 
166
- inputs: preferred format for function inputs. Must include action; extra keys are sent to the server as event.parameters.
166
+ functionApiName: API name of the function to invoke.
167
+ inputs: function inputs. Must include action; extra keys are sent to the server as event.parameters.
167
168
  responsePath (client-side): stores response body at that state path. Body must match the state shape (e.g. array, NOT wrapped in { data: [...] }).
168
169
  onSuccess (client-side): runs after handler resolves. Must use { set: { "/path": value } } format, NOT actions.set().
169
170
  onError (client-side): runs if handler throws. Same format as onSuccess.