@presolve/typescript-authority 0.2.0-beta.1 → 0.2.0-beta.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@presolve/typescript-authority",
3
- "version": "0.2.0-beta.1",
3
+ "version": "0.2.0-beta.3",
4
4
  "description": "The sole TypeScript semantic-authority boundary for Presolve.",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "type": "module",
@@ -20,10 +20,12 @@ export async function analyzeV2Authoring(request) {
20
20
  ...(request.canonical.state ? [{ id: "canonical:state", ...request.canonical.state }] : []),
21
21
  ...(request.canonical.action ? [{ id: "canonical:action", ...request.canonical.action }] : []),
22
22
  ...(request.canonical.effect ? [{ id: "canonical:effect", ...request.canonical.effect }] : []),
23
+ ...(request.canonical.slot ? [{ id: "canonical:slot", ...request.canonical.slot }] : []),
23
24
  ...(request.canonical.environment ? [{ id: "canonical:environment", ...request.canonical.environment }] : []),
24
25
  ...request.states.map(site => ({ id: `state:${site.id}`, file: site.file, position: site.position })),
25
26
  ...request.actions.map(site => ({ id: `action:${site.id}`, file: site.file, position: site.position })),
26
27
  ...request.effects.map(site => ({ id: `effect:${site.id}`, file: site.file, position: site.position })),
28
+ ...request.slots.map(site => ({ id: `slot:${site.id}`, file: site.file, position: site.position })),
27
29
  ...request.environmentPublic.flatMap(site => [
28
30
  { id: `environment-object:${site.id}`, file: site.file, position: site.objectPosition },
29
31
  { id: `environment-property:${site.id}`, file: site.file, position: site.propertyPosition },
@@ -46,6 +48,7 @@ export async function analyzeV2Authoring(request) {
46
48
  ...(request.canonical.state ? [{ kind: "state", symbol: symbols.get("canonical:state") }] : []),
47
49
  ...(request.canonical.action ? [{ kind: "action", symbol: symbols.get("canonical:action") }] : []),
48
50
  ...(request.canonical.effect ? [{ kind: "effect", symbol: symbols.get("canonical:effect") }] : []),
51
+ ...(request.canonical.slot ? [{ kind: "slot", symbol: symbols.get("canonical:slot") }] : []),
49
52
  ...(request.canonical.environment ? [{ kind: "environment_public", symbol: symbols.get("canonical:environment") }] : []),
50
53
  ]);
51
54
  return {
@@ -67,6 +70,10 @@ export async function analyzeV2Authoring(request) {
67
70
  const intrinsic = classifyResolvedIntrinsic(registry, symbols.get(`effect:${site.id}`));
68
71
  return intrinsic?.kind === "effect" ? [{ id: site.id, identity: intrinsic.identity }] : [];
69
72
  }),
73
+ slots: request.slots.flatMap(site => {
74
+ const intrinsic = classifyResolvedIntrinsic(registry, symbols.get(`slot:${site.id}`));
75
+ return intrinsic?.kind === "slot" ? [{ id: site.id, identity: intrinsic.identity }] : [];
76
+ }),
70
77
  environmentPublic: request.environmentPublic.flatMap(site => {
71
78
  const receiver = classifyResolvedIntrinsic(registry, symbols.get(`environment-object:${site.id}`));
72
79
  const member = resolvedIdentity(symbols.get(`environment-property:${site.id}`));
@@ -88,12 +95,12 @@ function validateV2AuthoringRequest(request) {
88
95
  if (request.schemaVersion !== V2_AUTHORED_AUTHORITY_SCHEMA_VERSION) {
89
96
  throw new TypeError(`unsupported V2 authoring authority schema version ${request.schemaVersion}`);
90
97
  }
91
- for (const kind of ["component", "state", "action", "effect", "environment"]) {
98
+ for (const kind of ["component", "state", "action", "effect", "slot", "environment"]) {
92
99
  if (request.canonical[kind] !== undefined) {
93
100
  validatePosition(request.canonical[kind], `canonical ${kind}`);
94
101
  }
95
102
  }
96
- for (const [kind, sites] of [["component", request.components], ["state", request.states], ["action", request.actions], ["effect", request.effects]]) {
103
+ for (const [kind, sites] of [["component", request.components], ["state", request.states], ["action", request.actions], ["effect", request.effects], ["slot", request.slots]]) {
97
104
  if (!Array.isArray(sites)) throw new TypeError(`V2 authoring ${kind} sites must be an array`);
98
105
  if (sites.length > 0 && request.canonical[kind] === undefined) {
99
106
  throw new TypeError(`V2 authoring ${kind} sites require a canonical ${kind} position`);
@@ -120,7 +120,7 @@ test("component heritage preserves aliases and indirect bases for registry class
120
120
  assert.equal(classifyResolvedComponentHeritage(registry, heritage.bases)?.kind, "component");
121
121
  });
122
122
 
123
- test("the V2 authoring bridge resolves canonical component, State, Action, Effect, and Environment evidence", async () => {
123
+ test("the V2 authoring bridge resolves canonical component, State, Action, Effect, Slot, and Environment evidence", async () => {
124
124
  const frameworkFile = resolve(root, "tests/framework-public-api/src/V2Counter.tsx");
125
125
  const frameworkSource = readFileSync(frameworkFile, "utf8");
126
126
  const result = await analyzeV2Authoring({
@@ -131,12 +131,14 @@ test("the V2 authoring bridge resolves canonical component, State, Action, Effec
131
131
  state: { file: frameworkFile, position: frameworkSource.indexOf("state") },
132
132
  action: { file: frameworkFile, position: frameworkSource.indexOf("action") },
133
133
  effect: { file: frameworkFile, position: frameworkSource.indexOf("effect") },
134
+ slot: { file: frameworkFile, position: frameworkSource.indexOf("slot") },
134
135
  environment: { file: frameworkFile, position: frameworkSource.indexOf("runtimeEnvironment") },
135
136
  },
136
137
  components: [{ id: "counter", file: frameworkFile, position: frameworkSource.indexOf("V2Counter extends") }],
137
138
  states: [{ id: "count", file: frameworkFile, position: frameworkSource.indexOf("state(0)") }],
138
139
  actions: [{ id: "increment", file: frameworkFile, position: frameworkSource.indexOf("action(()") }],
139
140
  effects: [{ id: "syncTitle", file: frameworkFile, position: frameworkSource.indexOf("effect(()") }],
141
+ slots: [{ id: "children", file: frameworkFile, position: frameworkSource.indexOf("slot()") }],
140
142
  environmentPublic: [
141
143
  {
142
144
  id: "application-name",
@@ -158,11 +160,13 @@ test("the V2 authoring bridge resolves canonical component, State, Action, Effec
158
160
  assert.deepEqual(result.states.map(entry => entry.id), ["count"]);
159
161
  assert.deepEqual(result.actions.map(entry => entry.id), ["increment"]);
160
162
  assert.deepEqual(result.effects.map(entry => entry.id), ["syncTitle"]);
163
+ assert.deepEqual(result.slots.map(entry => entry.id), ["children"]);
161
164
  assert.deepEqual(result.environmentPublic.map(entry => entry.id), ["application-name"]);
162
165
  assert.equal(result.components[0].identity.name, "Component");
163
166
  assert.equal(result.states[0].identity.name, "state");
164
167
  assert.equal(result.actions[0].identity.name, "action");
165
168
  assert.equal(result.effects[0].identity.name, "effect");
169
+ assert.equal(result.slots[0].identity.name, "slot");
166
170
  assert.equal(result.environmentPublic[0].identity.name, "public");
167
171
  });
168
172
 
@@ -179,6 +183,7 @@ test("the V2 authoring bridge supports a component-only discovery phase", async
179
183
  states: [],
180
184
  actions: [],
181
185
  effects: [],
186
+ slots: [],
182
187
  environmentPublic: [],
183
188
  });
184
189
  assert.deepEqual(result.components.map(entry => entry.id), ["counter"]);
@@ -202,6 +207,7 @@ test("the V2 authoring bridge recognizes a direct Component heritage-expression
202
207
  states: [],
203
208
  actions: [],
204
209
  effects: [],
210
+ slots: [],
205
211
  environmentPublic: [],
206
212
  });
207
213
  assert.deepEqual(result.components.map(entry => entry.id), ["direct"]);
@@ -221,6 +227,7 @@ test("the V2 authoring bridge resolves environment evidence without a component
221
227
  states: [],
222
228
  actions: [],
223
229
  effects: [],
230
+ slots: [],
224
231
  environmentPublic: [{
225
232
  id: "application-name",
226
233
  file: frameworkFile,
@@ -247,12 +254,14 @@ test("the V2 authoring executable speaks the versioned stdin/stdout bridge proto
247
254
  state: { file: frameworkFile, position: frameworkSource.indexOf("state") },
248
255
  action: { file: frameworkFile, position: frameworkSource.indexOf("action") },
249
256
  effect: { file: frameworkFile, position: frameworkSource.indexOf("effect") },
257
+ slot: { file: frameworkFile, position: frameworkSource.indexOf("slot") },
250
258
  environment: { file: frameworkFile, position: frameworkSource.indexOf("runtimeEnvironment") },
251
259
  },
252
260
  components: [{ id: "counter", file: frameworkFile, position: frameworkSource.indexOf("V2Counter extends") }],
253
261
  states: [{ id: "count", file: frameworkFile, position: frameworkSource.indexOf("state(0)") }],
254
262
  actions: [{ id: "increment", file: frameworkFile, position: frameworkSource.indexOf("action(()") }],
255
263
  effects: [{ id: "syncTitle", file: frameworkFile, position: frameworkSource.indexOf("effect(()") }],
264
+ slots: [{ id: "children", file: frameworkFile, position: frameworkSource.indexOf("slot()") }],
256
265
  environmentPublic: [],
257
266
  }),
258
267
  encoding: "utf8",
@@ -262,4 +271,5 @@ test("the V2 authoring executable speaks the versioned stdin/stdout bridge proto
262
271
  const response = JSON.parse(result.stdout);
263
272
  assert.equal(response.schemaVersion, V2_AUTHORED_AUTHORITY_SCHEMA_VERSION);
264
273
  assert.deepEqual(response.components.map(entry => entry.id), ["counter"]);
274
+ assert.deepEqual(response.slots.map(entry => entry.id), ["children"]);
265
275
  });