@open-mercato/cli 0.6.2-develop.3461.1.605f31c2c9 → 0.6.2

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.
@@ -112,6 +112,7 @@ function createNotificationsExtension() {
112
112
  fileName: "notifications.generated.ts",
113
113
  imports: [
114
114
  { namedImports: [{ name: "NotificationTypeDefinition", isTypeOnly: true }], moduleSpecifier: "@open-mercato/shared/modules/notifications/types" },
115
+ { namedImports: [{ name: "applyNotificationTypeOverridesToEntries" }], moduleSpecifier: "@open-mercato/shared/modules/overrides" },
115
116
  ...notificationImports
116
117
  ],
117
118
  build(sourceFile) {
@@ -127,9 +128,13 @@ function createNotificationsExtension() {
127
128
  type: "NotificationTypeEntry[]",
128
129
  initializer: arrayLiteral(notificationTypeEntries, writeValue)
129
130
  },
131
+ {
132
+ name: "entries",
133
+ initializer: callExpression(identifier("applyNotificationTypeOverridesToEntries"), [identifier("entriesRaw")])
134
+ },
130
135
  {
131
136
  name: "allTypes",
132
- initializer: methodCall(identifier("entriesRaw"), "flatMap", [
137
+ initializer: methodCall(identifier("entries"), "flatMap", [
133
138
  arrowFunction({
134
139
  parameters: ["entry"],
135
140
  body: propertyAccess(identifier("entry"), "types")
@@ -142,7 +147,7 @@ function createNotificationsExtension() {
142
147
  declarationKind: VariableDeclarationKind.Const,
143
148
  isExported: true,
144
149
  declarations: [
145
- { name: "notificationTypeEntries", initializer: identifier("entriesRaw") },
150
+ { name: "notificationTypeEntries", initializer: identifier("entries") },
146
151
  { name: "notificationTypes", initializer: identifier("allTypes") }
147
152
  ]
148
153
  });
@@ -181,6 +186,7 @@ function createNotificationsExtension() {
181
186
  ],
182
187
  moduleSpecifier: "@open-mercato/shared/modules/notifications/types"
183
188
  },
189
+ { namedImports: [{ name: "applyNotificationTypeOverridesToEntries" }], moduleSpecifier: "@open-mercato/shared/modules/overrides" },
184
190
  ...notificationClientImports
185
191
  ],
186
192
  build(sourceFile) {
@@ -201,9 +207,13 @@ function createNotificationsExtension() {
201
207
  type: "NotificationTypeEntry[]",
202
208
  initializer: arrayLiteral(notificationClientTypeEntries, writeValue)
203
209
  },
210
+ {
211
+ name: "entries",
212
+ initializer: callExpression(identifier("applyNotificationTypeOverridesToEntries"), [identifier("entriesRaw")])
213
+ },
204
214
  {
205
215
  name: "allTypes",
206
- initializer: methodCall(identifier("entriesRaw"), "flatMap", [
216
+ initializer: methodCall(identifier("entries"), "flatMap", [
207
217
  arrowFunction({
208
218
  parameters: ["entry"],
209
219
  body: propertyAccess(identifier("entry"), "types")
@@ -243,7 +253,7 @@ function createNotificationsExtension() {
243
253
  declarationKind: VariableDeclarationKind.Const,
244
254
  isExported: true,
245
255
  declarations: [
246
- { name: "notificationClientTypeEntries", initializer: identifier("entriesRaw") },
256
+ { name: "notificationClientTypeEntries", initializer: identifier("entries") },
247
257
  { name: "notificationClientTypes", initializer: identifier("allTypes") },
248
258
  { name: "notificationRenderers", initializer: identifier("renderers") }
249
259
  ]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/lib/generators/extensions/notifications.ts"],
4
- "sourcesContent": ["import { VariableDeclarationKind, type WriterFunction } from 'ts-morph'\nimport type { GeneratorExtension } from '../extension'\nimport {\n arrayLiteral,\n arrowFunction,\n binaryExpression,\n callExpression,\n identifier,\n methodCall,\n nonNullAssertion,\n objectFromEntries,\n optionalPropertyAccess,\n propertyAccess,\n returnStatement,\n writeValue,\n} from '../ast'\nimport {\n emptyArray,\n moduleEntry,\n namespaceFallback,\n namespaceImportSpec,\n renderGeneratedTsSource,\n sideEffectImportSpec,\n} from './shared'\n\nexport function createNotificationsExtension(): GeneratorExtension {\n const notificationImports: Array<ReturnType<typeof namespaceImportSpec>> = []\n const notificationTypeEntries: WriterFunction[] = []\n const notificationClientImports: Array<ReturnType<typeof namespaceImportSpec>> = []\n const notificationClientTypeEntries: WriterFunction[] = []\n const paymentClientImports: Array<ReturnType<typeof sideEffectImportSpec>> = []\n const notificationHandlerImports: Array<ReturnType<typeof namespaceImportSpec>> = []\n const notificationHandlerEntries: WriterFunction[] = []\n\n return {\n id: 'registry.notifications',\n outputFiles: [\n 'notifications.generated.ts',\n 'notifications.client.generated.ts',\n 'payments.client.generated.ts',\n 'notification-handlers.generated.ts',\n ],\n scanModule(ctx) {\n ctx.processStandaloneConfig({\n roots: ctx.roots,\n imps: ctx.imps,\n modId: ctx.moduleId,\n relativePath: 'notifications.ts',\n prefix: 'NOTIF',\n importIdRef: ctx.importIdRef,\n standaloneImports: notificationImports,\n standaloneEntries: notificationTypeEntries,\n writeConfig: ({ importName, moduleId }) =>\n moduleEntry(moduleId, [\n {\n name: 'types',\n value: namespaceFallback({\n importName,\n members: ['default', 'notificationTypes', 'types'],\n fallback: emptyArray(),\n castType: 'NotificationTypeDefinition[]',\n }),\n },\n ]),\n })\n\n ctx.processStandaloneConfig({\n roots: ctx.roots,\n imps: ctx.imps,\n modId: ctx.moduleId,\n relativePath: 'notifications.client.ts',\n prefix: 'NOTIF_CLIENT',\n importIdRef: ctx.importIdRef,\n standaloneImports: notificationClientImports,\n standaloneEntries: notificationClientTypeEntries,\n writeConfig: ({ importName, moduleId }) =>\n moduleEntry(moduleId, [\n {\n name: 'types',\n value: namespaceFallback({\n importName,\n members: ['default'],\n fallback: emptyArray(),\n castType: 'NotificationTypeDefinition[]',\n }),\n },\n ]),\n })\n\n const paymentClient = ctx.resolveFirstModuleFile(ctx.roots, ctx.imps, [\n 'widgets/payments/client.tsx',\n 'widgets/payments/client.ts',\n ])\n if (paymentClient) {\n paymentClientImports.push(sideEffectImportSpec(paymentClient.importPath))\n }\n\n ctx.processStandaloneConfig({\n roots: ctx.roots,\n imps: ctx.imps,\n modId: ctx.moduleId,\n relativePath: 'notifications.handlers.ts',\n prefix: 'NOTIF_HANDLERS',\n importIdRef: ctx.importIdRef,\n standaloneImports: notificationHandlerImports,\n standaloneEntries: notificationHandlerEntries,\n writeConfig: ({ importName, moduleId }) =>\n moduleEntry(moduleId, [\n {\n name: 'handlers',\n value: namespaceFallback({\n importName,\n members: ['default', 'notificationHandlers'],\n fallback: emptyArray(),\n castType: 'NotificationHandler[]',\n }),\n },\n ]),\n })\n },\n generateOutput() {\n const notificationsOutput = renderGeneratedTsSource({\n fileName: 'notifications.generated.ts',\n imports: [\n { namedImports: [{ name: 'NotificationTypeDefinition', isTypeOnly: true }], moduleSpecifier: '@open-mercato/shared/modules/notifications/types' },\n ...notificationImports,\n ],\n build(sourceFile) {\n sourceFile.addTypeAlias({\n name: 'NotificationTypeEntry',\n type: '{ moduleId: string; types: NotificationTypeDefinition[] }',\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'entriesRaw',\n type: 'NotificationTypeEntry[]',\n initializer: arrayLiteral(notificationTypeEntries, writeValue),\n },\n {\n name: 'allTypes',\n initializer: methodCall(identifier('entriesRaw'), 'flatMap', [\n arrowFunction({\n parameters: ['entry'],\n body: propertyAccess(identifier('entry'), 'types'),\n }),\n ]),\n },\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'notificationTypeEntries', initializer: identifier('entriesRaw') },\n { name: 'notificationTypes', initializer: identifier('allTypes') },\n ],\n })\n sourceFile.addFunction({\n name: 'getNotificationTypes',\n isExported: true,\n returnType: 'NotificationTypeDefinition[]',\n statements: [returnStatement(identifier('allTypes'))],\n })\n sourceFile.addFunction({\n name: 'getNotificationType',\n isExported: true,\n parameters: [{ name: 'type', type: 'string' }],\n returnType: 'NotificationTypeDefinition | undefined',\n statements: [\n returnStatement(\n methodCall(identifier('allTypes'), 'find', [\n arrowFunction({\n parameters: ['entry'],\n body: binaryExpression(propertyAccess(identifier('entry'), 'type'), '===', identifier('type')),\n }),\n ]),\n ),\n ],\n })\n },\n })\n\n const notificationsClientOutput = renderGeneratedTsSource({\n fileName: 'notifications.client.generated.ts',\n imports: [\n { namedImports: [{ name: 'ComponentType', isTypeOnly: true }], moduleSpecifier: 'react' },\n {\n namedImports: [\n { name: 'NotificationTypeDefinition', isTypeOnly: true },\n { name: 'NotificationRendererProps', isTypeOnly: true },\n ],\n moduleSpecifier: '@open-mercato/shared/modules/notifications/types',\n },\n ...notificationClientImports,\n ],\n build(sourceFile) {\n sourceFile.addTypeAlias({\n name: 'NotificationTypeEntry',\n type: '{ moduleId: string; types: NotificationTypeDefinition[] }',\n })\n sourceFile.addTypeAlias({\n name: 'NotificationRenderers',\n isExported: true,\n type: 'Record<string, ComponentType<NotificationRendererProps>>',\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'entriesRaw',\n type: 'NotificationTypeEntry[]',\n initializer: arrayLiteral(notificationClientTypeEntries, writeValue),\n },\n {\n name: 'allTypes',\n initializer: methodCall(identifier('entriesRaw'), 'flatMap', [\n arrowFunction({\n parameters: ['entry'],\n body: propertyAccess(identifier('entry'), 'types'),\n }),\n ]),\n },\n {\n name: 'renderers',\n type: 'NotificationRenderers',\n initializer: objectFromEntries(\n methodCall(\n methodCall(identifier('allTypes'), 'filter', [\n arrowFunction({\n parameters: ['typeDef'],\n body: callExpression(identifier('Boolean'), [propertyAccess(identifier('typeDef'), 'Renderer')]),\n }),\n ]),\n 'map',\n [\n arrowFunction({\n parameters: ['typeDef'],\n body: arrayLiteral(\n [\n propertyAccess(identifier('typeDef'), 'type'),\n nonNullAssertion(propertyAccess(identifier('typeDef'), 'Renderer')),\n ],\n writeValue,\n ),\n }),\n ],\n ),\n ),\n },\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'notificationClientTypeEntries', initializer: identifier('entriesRaw') },\n { name: 'notificationClientTypes', initializer: identifier('allTypes') },\n { name: 'notificationRenderers', initializer: identifier('renderers') },\n ],\n })\n sourceFile.addFunction({\n name: 'getNotificationRenderers',\n isExported: true,\n returnType: 'NotificationRenderers',\n statements: [returnStatement(identifier('renderers'))],\n })\n },\n })\n\n const paymentsClientOutput = renderGeneratedTsSource({\n fileName: 'payments.client.generated.ts',\n imports: paymentClientImports,\n build(sourceFile) {\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'paymentGatewayClientModuleCount', initializer: String(paymentClientImports.length) },\n ],\n })\n },\n })\n\n const notificationHandlersOutput = renderGeneratedTsSource({\n fileName: 'notification-handlers.generated.ts',\n imports: [\n { namedImports: [{ name: 'NotificationHandler', isTypeOnly: true }], moduleSpecifier: '@open-mercato/shared/modules/notifications/handler' },\n ...notificationHandlerImports,\n ],\n build(sourceFile) {\n sourceFile.addTypeAlias({\n name: 'NotificationHandlerEntry',\n type: '{ moduleId: string; handlers: NotificationHandler[] }',\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'notificationHandlerEntries',\n type: 'NotificationHandlerEntry[]',\n initializer: arrayLiteral(notificationHandlerEntries, writeValue),\n },\n ],\n })\n },\n })\n\n return new Map([\n ['notifications.generated.ts', notificationsOutput],\n ['notifications.client.generated.ts', notificationsClientOutput],\n ['payments.client.generated.ts', paymentsClientOutput],\n ['notification-handlers.generated.ts', notificationHandlersOutput],\n ])\n },\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,+BAAoD;AAE7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEA,SAAS,+BAAmD;AACjE,QAAM,sBAAqE,CAAC;AAC5E,QAAM,0BAA4C,CAAC;AACnD,QAAM,4BAA2E,CAAC;AAClF,QAAM,gCAAkD,CAAC;AACzD,QAAM,uBAAuE,CAAC;AAC9E,QAAM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CAAC,qCAAqC,yBAAyB;AAAA,QAC/D,CAAC,gCAAgC,oBAAoB;AAAA,QACrD,CAAC,sCAAsC,0BAA0B;AAAA,MACnE,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import { VariableDeclarationKind, type WriterFunction } from 'ts-morph'\nimport type { GeneratorExtension } from '../extension'\nimport {\n arrayLiteral,\n arrowFunction,\n binaryExpression,\n callExpression,\n identifier,\n methodCall,\n nonNullAssertion,\n objectFromEntries,\n optionalPropertyAccess,\n propertyAccess,\n returnStatement,\n writeValue,\n} from '../ast'\nimport {\n emptyArray,\n moduleEntry,\n namespaceFallback,\n namespaceImportSpec,\n renderGeneratedTsSource,\n sideEffectImportSpec,\n} from './shared'\n\nexport function createNotificationsExtension(): GeneratorExtension {\n const notificationImports: Array<ReturnType<typeof namespaceImportSpec>> = []\n const notificationTypeEntries: WriterFunction[] = []\n const notificationClientImports: Array<ReturnType<typeof namespaceImportSpec>> = []\n const notificationClientTypeEntries: WriterFunction[] = []\n const paymentClientImports: Array<ReturnType<typeof sideEffectImportSpec>> = []\n const notificationHandlerImports: Array<ReturnType<typeof namespaceImportSpec>> = []\n const notificationHandlerEntries: WriterFunction[] = []\n\n return {\n id: 'registry.notifications',\n outputFiles: [\n 'notifications.generated.ts',\n 'notifications.client.generated.ts',\n 'payments.client.generated.ts',\n 'notification-handlers.generated.ts',\n ],\n scanModule(ctx) {\n ctx.processStandaloneConfig({\n roots: ctx.roots,\n imps: ctx.imps,\n modId: ctx.moduleId,\n relativePath: 'notifications.ts',\n prefix: 'NOTIF',\n importIdRef: ctx.importIdRef,\n standaloneImports: notificationImports,\n standaloneEntries: notificationTypeEntries,\n writeConfig: ({ importName, moduleId }) =>\n moduleEntry(moduleId, [\n {\n name: 'types',\n value: namespaceFallback({\n importName,\n members: ['default', 'notificationTypes', 'types'],\n fallback: emptyArray(),\n castType: 'NotificationTypeDefinition[]',\n }),\n },\n ]),\n })\n\n ctx.processStandaloneConfig({\n roots: ctx.roots,\n imps: ctx.imps,\n modId: ctx.moduleId,\n relativePath: 'notifications.client.ts',\n prefix: 'NOTIF_CLIENT',\n importIdRef: ctx.importIdRef,\n standaloneImports: notificationClientImports,\n standaloneEntries: notificationClientTypeEntries,\n writeConfig: ({ importName, moduleId }) =>\n moduleEntry(moduleId, [\n {\n name: 'types',\n value: namespaceFallback({\n importName,\n members: ['default'],\n fallback: emptyArray(),\n castType: 'NotificationTypeDefinition[]',\n }),\n },\n ]),\n })\n\n const paymentClient = ctx.resolveFirstModuleFile(ctx.roots, ctx.imps, [\n 'widgets/payments/client.tsx',\n 'widgets/payments/client.ts',\n ])\n if (paymentClient) {\n paymentClientImports.push(sideEffectImportSpec(paymentClient.importPath))\n }\n\n ctx.processStandaloneConfig({\n roots: ctx.roots,\n imps: ctx.imps,\n modId: ctx.moduleId,\n relativePath: 'notifications.handlers.ts',\n prefix: 'NOTIF_HANDLERS',\n importIdRef: ctx.importIdRef,\n standaloneImports: notificationHandlerImports,\n standaloneEntries: notificationHandlerEntries,\n writeConfig: ({ importName, moduleId }) =>\n moduleEntry(moduleId, [\n {\n name: 'handlers',\n value: namespaceFallback({\n importName,\n members: ['default', 'notificationHandlers'],\n fallback: emptyArray(),\n castType: 'NotificationHandler[]',\n }),\n },\n ]),\n })\n },\n generateOutput() {\n const notificationsOutput = renderGeneratedTsSource({\n fileName: 'notifications.generated.ts',\n imports: [\n { namedImports: [{ name: 'NotificationTypeDefinition', isTypeOnly: true }], moduleSpecifier: '@open-mercato/shared/modules/notifications/types' },\n { namedImports: [{ name: 'applyNotificationTypeOverridesToEntries' }], moduleSpecifier: '@open-mercato/shared/modules/overrides' },\n ...notificationImports,\n ],\n build(sourceFile) {\n sourceFile.addTypeAlias({\n name: 'NotificationTypeEntry',\n type: '{ moduleId: string; types: NotificationTypeDefinition[] }',\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'entriesRaw',\n type: 'NotificationTypeEntry[]',\n initializer: arrayLiteral(notificationTypeEntries, writeValue),\n },\n {\n name: 'entries',\n initializer: callExpression(identifier('applyNotificationTypeOverridesToEntries'), [identifier('entriesRaw')]),\n },\n {\n name: 'allTypes',\n initializer: methodCall(identifier('entries'), 'flatMap', [\n arrowFunction({\n parameters: ['entry'],\n body: propertyAccess(identifier('entry'), 'types'),\n }),\n ]),\n },\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'notificationTypeEntries', initializer: identifier('entries') },\n { name: 'notificationTypes', initializer: identifier('allTypes') },\n ],\n })\n sourceFile.addFunction({\n name: 'getNotificationTypes',\n isExported: true,\n returnType: 'NotificationTypeDefinition[]',\n statements: [returnStatement(identifier('allTypes'))],\n })\n sourceFile.addFunction({\n name: 'getNotificationType',\n isExported: true,\n parameters: [{ name: 'type', type: 'string' }],\n returnType: 'NotificationTypeDefinition | undefined',\n statements: [\n returnStatement(\n methodCall(identifier('allTypes'), 'find', [\n arrowFunction({\n parameters: ['entry'],\n body: binaryExpression(propertyAccess(identifier('entry'), 'type'), '===', identifier('type')),\n }),\n ]),\n ),\n ],\n })\n },\n })\n\n const notificationsClientOutput = renderGeneratedTsSource({\n fileName: 'notifications.client.generated.ts',\n imports: [\n { namedImports: [{ name: 'ComponentType', isTypeOnly: true }], moduleSpecifier: 'react' },\n {\n namedImports: [\n { name: 'NotificationTypeDefinition', isTypeOnly: true },\n { name: 'NotificationRendererProps', isTypeOnly: true },\n ],\n moduleSpecifier: '@open-mercato/shared/modules/notifications/types',\n },\n { namedImports: [{ name: 'applyNotificationTypeOverridesToEntries' }], moduleSpecifier: '@open-mercato/shared/modules/overrides' },\n ...notificationClientImports,\n ],\n build(sourceFile) {\n sourceFile.addTypeAlias({\n name: 'NotificationTypeEntry',\n type: '{ moduleId: string; types: NotificationTypeDefinition[] }',\n })\n sourceFile.addTypeAlias({\n name: 'NotificationRenderers',\n isExported: true,\n type: 'Record<string, ComponentType<NotificationRendererProps>>',\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'entriesRaw',\n type: 'NotificationTypeEntry[]',\n initializer: arrayLiteral(notificationClientTypeEntries, writeValue),\n },\n {\n name: 'entries',\n initializer: callExpression(identifier('applyNotificationTypeOverridesToEntries'), [identifier('entriesRaw')]),\n },\n {\n name: 'allTypes',\n initializer: methodCall(identifier('entries'), 'flatMap', [\n arrowFunction({\n parameters: ['entry'],\n body: propertyAccess(identifier('entry'), 'types'),\n }),\n ]),\n },\n {\n name: 'renderers',\n type: 'NotificationRenderers',\n initializer: objectFromEntries(\n methodCall(\n methodCall(identifier('allTypes'), 'filter', [\n arrowFunction({\n parameters: ['typeDef'],\n body: callExpression(identifier('Boolean'), [propertyAccess(identifier('typeDef'), 'Renderer')]),\n }),\n ]),\n 'map',\n [\n arrowFunction({\n parameters: ['typeDef'],\n body: arrayLiteral(\n [\n propertyAccess(identifier('typeDef'), 'type'),\n nonNullAssertion(propertyAccess(identifier('typeDef'), 'Renderer')),\n ],\n writeValue,\n ),\n }),\n ],\n ),\n ),\n },\n ],\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'notificationClientTypeEntries', initializer: identifier('entries') },\n { name: 'notificationClientTypes', initializer: identifier('allTypes') },\n { name: 'notificationRenderers', initializer: identifier('renderers') },\n ],\n })\n sourceFile.addFunction({\n name: 'getNotificationRenderers',\n isExported: true,\n returnType: 'NotificationRenderers',\n statements: [returnStatement(identifier('renderers'))],\n })\n },\n })\n\n const paymentsClientOutput = renderGeneratedTsSource({\n fileName: 'payments.client.generated.ts',\n imports: paymentClientImports,\n build(sourceFile) {\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n { name: 'paymentGatewayClientModuleCount', initializer: String(paymentClientImports.length) },\n ],\n })\n },\n })\n\n const notificationHandlersOutput = renderGeneratedTsSource({\n fileName: 'notification-handlers.generated.ts',\n imports: [\n { namedImports: [{ name: 'NotificationHandler', isTypeOnly: true }], moduleSpecifier: '@open-mercato/shared/modules/notifications/handler' },\n ...notificationHandlerImports,\n ],\n build(sourceFile) {\n sourceFile.addTypeAlias({\n name: 'NotificationHandlerEntry',\n type: '{ moduleId: string; handlers: NotificationHandler[] }',\n })\n sourceFile.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n isExported: true,\n declarations: [\n {\n name: 'notificationHandlerEntries',\n type: 'NotificationHandlerEntry[]',\n initializer: arrayLiteral(notificationHandlerEntries, writeValue),\n },\n ],\n })\n },\n })\n\n return new Map([\n ['notifications.generated.ts', notificationsOutput],\n ['notifications.client.generated.ts', notificationsClientOutput],\n ['payments.client.generated.ts', paymentsClientOutput],\n ['notification-handlers.generated.ts', notificationHandlersOutput],\n ])\n },\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,+BAAoD;AAE7D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEA,SAAS,+BAAmD;AACjE,QAAM,sBAAqE,CAAC;AAC5E,QAAM,0BAA4C,CAAC;AACnD,QAAM,4BAA2E,CAAC;AAClF,QAAM,gCAAkD,CAAC;AACzD,QAAM,uBAAuE,CAAC;AAC9E,QAAM,6BAA4E,CAAC;AACnF,QAAM,6BAA+C,CAAC;AAEtD,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,aAAa;AAAA,MACX;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,IACA,WAAW,KAAK;AACd,UAAI,wBAAwB;AAAA,QAC1B,OAAO,IAAI;AAAA,QACX,MAAM,IAAI;AAAA,QACV,OAAO,IAAI;AAAA,QACX,cAAc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F;AAAA,UACF,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AAED,aAAO,oBAAI,IAAI;AAAA,QACb,CAAC,8BAA8B,mBAAmB;AAAA,QAClD,CAAC,qCAAqC,yBAAyB;AAAA,QAC/D,CAAC,gCAAgC,oBAAoB;AAAA,QACrD,CAAC,sCAAsC,0BAA0B;AAAA,MACnE,CAAC;AAAA,IACH;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -630,8 +630,9 @@ function requiresRuntimePageMetadataFromSourceFile(sourceFile) {
630
630
  function toLiteral(value) {
631
631
  return JSON.stringify(value).replace(/</g, "\\u003c").replace(/>/g, "\\u003e").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
632
632
  }
633
- const GENERATED_MODULE_SPECIFIER_PREFIXES = ["@/", "@open-mercato/", "../../src/modules/", "./"];
633
+ const GENERATED_MODULE_RELATIVE_PREFIXES = ["@/", "../../src/modules/", "./"];
634
634
  const GENERATED_MODULE_SPECIFIER_SEGMENT = /^[A-Za-z0-9_.\-[\]()']+$/;
635
+ const NPM_PACKAGE_NAME_SEGMENT = /^[A-Za-z0-9~][A-Za-z0-9_.~-]*$/;
635
636
  function sanitizeGeneratedModuleSpecifierSegment(segment, importPath) {
636
637
  const match = GENERATED_MODULE_SPECIFIER_SEGMENT.exec(segment);
637
638
  if (!match || segment === "." || segment === "..") {
@@ -639,17 +640,64 @@ function sanitizeGeneratedModuleSpecifierSegment(segment, importPath) {
639
640
  }
640
641
  return match[0];
641
642
  }
642
- function sanitizeGeneratedModuleSpecifier(importPath) {
643
- const prefix = GENERATED_MODULE_SPECIFIER_PREFIXES.find((candidate) => importPath.startsWith(candidate));
644
- if (!prefix) {
645
- throw new Error(`Unsafe generated module specifier prefix: ${importPath}`);
643
+ function sanitizeNpmPackageNameSegment(segment, importPath) {
644
+ if (!NPM_PACKAGE_NAME_SEGMENT.test(segment) || segment === "." || segment === "..") {
645
+ throw new Error(`Unsafe generated module specifier: ${importPath}`);
646
646
  }
647
- const suffix = importPath.slice(prefix.length);
648
- if (!suffix) {
647
+ }
648
+ function sanitizeGeneratedModuleSpecifier(importPath) {
649
+ if (!importPath) {
649
650
  throw new Error(`Unsafe generated module specifier: ${importPath}`);
650
651
  }
651
- const segments = suffix.split("/").map((segment) => sanitizeGeneratedModuleSpecifierSegment(segment, importPath));
652
- return `${prefix}${segments.join("/")}`;
652
+ const relativePrefix = GENERATED_MODULE_RELATIVE_PREFIXES.find(
653
+ (candidate) => importPath.startsWith(candidate)
654
+ );
655
+ if (relativePrefix) {
656
+ const suffix = importPath.slice(relativePrefix.length);
657
+ if (!suffix) {
658
+ throw new Error(`Unsafe generated module specifier: ${importPath}`);
659
+ }
660
+ const segments2 = suffix.split("/").map((segment) => sanitizeGeneratedModuleSpecifierSegment(segment, importPath));
661
+ return `${relativePrefix}${segments2.join("/")}`;
662
+ }
663
+ if (importPath.startsWith("@")) {
664
+ const firstSlash2 = importPath.indexOf("/");
665
+ if (firstSlash2 < 2) {
666
+ throw new Error(`Unsafe generated module specifier prefix: ${importPath}`);
667
+ }
668
+ const scope = importPath.slice(1, firstSlash2);
669
+ sanitizeNpmPackageNameSegment(scope, importPath);
670
+ const rest = importPath.slice(firstSlash2 + 1);
671
+ if (!rest) {
672
+ throw new Error(`Unsafe generated module specifier: ${importPath}`);
673
+ }
674
+ const secondSlash = rest.indexOf("/");
675
+ const name2 = secondSlash >= 0 ? rest.slice(0, secondSlash) : rest;
676
+ sanitizeNpmPackageNameSegment(name2, importPath);
677
+ const subpath2 = secondSlash >= 0 ? rest.slice(secondSlash + 1) : "";
678
+ if (!subpath2) {
679
+ return `@${scope}/${name2}`;
680
+ }
681
+ const segments2 = subpath2.split("/").map((segment) => sanitizeGeneratedModuleSpecifierSegment(segment, importPath));
682
+ return `@${scope}/${name2}/${segments2.join("/")}`;
683
+ }
684
+ const firstSlash = importPath.indexOf("/");
685
+ const name = firstSlash >= 0 ? importPath.slice(0, firstSlash) : importPath;
686
+ sanitizeNpmPackageNameSegment(name, importPath);
687
+ const subpath = firstSlash >= 0 ? importPath.slice(firstSlash + 1) : "";
688
+ if (!subpath) {
689
+ return name;
690
+ }
691
+ const segments = subpath.split("/").map((segment) => sanitizeGeneratedModuleSpecifierSegment(segment, importPath));
692
+ return `${name}/${segments.join("/")}`;
693
+ }
694
+ function verifyThirdPartyModuleShape(entry, pkgBase) {
695
+ const from = entry.from;
696
+ if (!from || from === "@app" || from.startsWith("@open-mercato/")) return;
697
+ if (fs.existsSync(pkgBase)) return;
698
+ throw new Error(
699
+ `Module '${entry.id}' is registered with from: '${from}' but no Open Mercato module shape was found at '${pkgBase}'. Ensure the package ships a 'modules/${entry.id}' subtree (either under 'dist/modules/' or 'src/modules/'), or correct the 'from' value in src/modules.ts.`
700
+ );
653
701
  }
654
702
  function buildImportStatement(importClause, importPath) {
655
703
  return `import ${importClause} from ${toLiteral(sanitizeGeneratedModuleSpecifier(importPath))}`;
@@ -1937,6 +1985,9 @@ async function generateModuleRegistry(options) {
1937
1985
  const legacySubscribersOutFile = path.join(outputDir, "subscribers.generated.ts");
1938
1986
  const legacySubscribersChecksumFile = path.join(outputDir, "subscribers.generated.checksum");
1939
1987
  const enabled = resolver.loadEnabledModules();
1988
+ for (const entry of enabled) {
1989
+ verifyThirdPartyModuleShape(entry, resolver.getModulePaths(entry).pkgBase);
1990
+ }
1940
1991
  const extensions = loadGeneratorExtensions();
1941
1992
  const pluginRegistry = /* @__PURE__ */ new Map();
1942
1993
  const pluginState = /* @__PURE__ */ new Map();
@@ -2475,6 +2526,9 @@ async function generateModuleRegistryApp(options) {
2475
2526
  const enabledIdsOutFile = path.join(outputDir, "enabled-module-ids.generated.ts");
2476
2527
  const enabledIdsChecksumFile = path.join(outputDir, "enabled-module-ids.generated.checksum");
2477
2528
  const enabled = resolver.loadEnabledModules();
2529
+ for (const entry of enabled) {
2530
+ verifyThirdPartyModuleShape(entry, resolver.getModulePaths(entry).pkgBase);
2531
+ }
2478
2532
  const imports = [];
2479
2533
  const moduleDecls = [];
2480
2534
  const importIdRef = { value: 0 };
@@ -2767,6 +2821,9 @@ async function generateModuleRegistryCli(options) {
2767
2821
  const legacyOutFile = path.join(outputDir, "cli-modules.generated.ts");
2768
2822
  const legacyChecksumFile = path.join(outputDir, "cli-modules.generated.checksum");
2769
2823
  const enabled = resolver.loadEnabledModules();
2824
+ for (const entry of enabled) {
2825
+ verifyThirdPartyModuleShape(entry, resolver.getModulePaths(entry).pkgBase);
2826
+ }
2770
2827
  const imports = [];
2771
2828
  const moduleDecls = [];
2772
2829
  const importIdRef = { value: 0 };