@slicemachine/plugin-kit 0.4.83-beta.3 → 0.4.84-alpha.lg-page-routes.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.
@@ -40,6 +40,7 @@ const REQUIRED_ADAPTER_HOOKS = [
40
40
  "custom-type:create",
41
41
  "custom-type:read",
42
42
  "custom-type:rename",
43
+ "custom-type:update-route",
43
44
  "custom-type:delete",
44
45
  "custom-type:update",
45
46
  "custom-type:asset:update",
@@ -1 +1 @@
1
- {"version":3,"file":"createSliceMachinePluginRunner.cjs","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["createSliceMachineActions","createSliceMachineHelpers","path","createRequire","defu","createSliceMachineContext","hook","createSliceMachineHookSystem"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BO,MAAM,yBAAkD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAKM,MAAM,qBAA8C;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;MAYY,yBAAwB;AAAA,EA+BpC,YAAY,EACX,SACA,YACA,gBAAgB,CAAA,KACyB;AAlClC;AACA;AACA;AAUR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA;AAAA;AACA;AACA;AACA;AAOC,SAAK,WAAW;AAChB,SAAK,cAAc;AACnB,SAAK,iBAAiB;AAEtB,SAAK,aAAaA,0BAAAA,0BACjB,KAAK,UACL,KAAK,WAAW;AAEjB,SAAK,aAAaC,oDAA0B,KAAK,QAAQ;AAEzD,SAAK,WAAW,KAAK,YAAY,SAAS,KAAK,KAAK,WAAW;AAC/D,SAAK,gBAAgB,KAAK,YAAY,cAAc,KAAK,KAAK,WAAW;AACzE,SAAK,eAAe,KAAK,YAAY,aAAa,KAAK,KAAK,WAAW;AACvE,SAAK,cAAc,KAAK,YAAY,YAAY,KAAK,KAAK,WAAW;AAAA,EACtE;AAAA,EAEQ,MAAM,YACb,oBAAwD;AAGxD,UAAM,EAAE,SAAS,UAAU,CAAA,MAC1B,OAAO,uBAAuB,YAAY,aAAa,qBACpD,qBACA,EAAE,SAAS,mBAAA;A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A;AAUM,MAAM,iCAAiC,CAAC,EAC9C,SACA,oBACkE;AAClE,QAAM,aAAaC,6BAAAA,6BAAA;AAEnB,SAAO,IAAI,yBAAyB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;;;;;"}
1
+ {"version":3,"file":"createSliceMachinePluginRunner.cjs","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:update-route\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["createSliceMachineActions","createSliceMachineHelpers","path","createRequire","defu","createSliceMachineContext","hook","createSliceMachineHookSystem"],"mappings":";;;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C;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;;;;;"}
@@ -21,6 +21,7 @@ const REQUIRED_ADAPTER_HOOKS = [
21
21
  "custom-type:create",
22
22
  "custom-type:read",
23
23
  "custom-type:rename",
24
+ "custom-type:update-route",
24
25
  "custom-type:delete",
25
26
  "custom-type:update",
26
27
  "custom-type:asset:update",
@@ -1 +1 @@
1
- {"version":3,"file":"createSliceMachinePluginRunner.js","sources":["../../src/createSliceMachinePluginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["hook"],"mappings":";;;;;;;;;;AA+BO,MAAM,y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ginRunner.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport _module, { createRequire } from \"node:module\";\n\nimport { defu } from \"defu\";\n\nimport { HookSystem } from \"./lib/HookSystem\";\nimport { createSliceMachineContext } from \"./createSliceMachineContext\";\nimport {\n\tLoadedSliceMachinePlugin,\n\tSliceMachinePlugin,\n} from \"./defineSliceMachinePlugin\";\nimport {\n\tSliceMachineConfigPluginRegistration,\n\tSliceMachineHookExtraArgs,\n\tSliceMachineHookTypes,\n\tSliceMachineHooks,\n\tSliceMachineProject,\n} from \"./types\";\nimport { createSliceMachineHookSystem } from \"./createSliceMachineHookSystem\";\nimport {\n\tcreateSliceMachineActions,\n\tSliceMachineActions,\n} from \"./createSliceMachineActions\";\nimport {\n\tcreateSliceMachineHelpers,\n\tSliceMachineHelpers,\n} from \"./createSliceMachineHelpers\";\n\n/**\n * @internal\n */\nexport const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:create\",\n\t\"slice:read\",\n\t\"slice:rename\",\n\t\"slice:delete\",\n\t\"slice:update\",\n\t\"slice:asset:update\",\n\t\"slice:asset:read\",\n\t\"slice:asset:delete\",\n\t\"slice-library:read\",\n\t\"custom-type:create\",\n\t\"custom-type:read\",\n\t\"custom-type:rename\",\n\t\"custom-type:update-route\",\n\t\"custom-type:delete\",\n\t\"custom-type:update\",\n\t\"custom-type:asset:update\",\n\t\"custom-type:asset:read\",\n\t\"custom-type:asset:delete\",\n\t\"custom-type-library:read\",\n];\n/**\n * @internal\n */\nexport const ADAPTER_ONLY_HOOKS: SliceMachineHookTypes[] = [\n\t\"slice:read\",\n\t\"slice:asset:read\",\n\t\"slice-library:read\",\n\t\"custom-type:read\",\n\t\"custom-type:asset:read\",\n\t\"custom-type-library:read\",\n\t\"project:environment:read\",\n];\n\ntype SliceMachinePluginRunnerConstructorArgs = {\n\tproject: SliceMachineProject;\n\thookSystem: HookSystem<SliceMachineHooks>;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport class SliceMachinePluginRunner {\n\tprivate _project: SliceMachineProject;\n\tprivate _hookSystem: HookSystem<SliceMachineHooks>;\n\tprivate _nativePlugins: Record<string, SliceMachinePlugin>;\n\n\t/**\n\t * Slice Machine actions provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawActions`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawActions: SliceMachineActions;\n\n\t/**\n\t * Slice Machine helpers provided to hooks.\n\t *\n\t * IMPORTANT: Prefer creating your own abstraction over using `rawHelpers`\n\t * directly to prevent code breakage if this internal API changes.\n\t *\n\t * @internal\n\t */\n\trawHelpers: SliceMachineHelpers;\n\n\t// Methods forwarded to the plugin runner's hook system.\n\tcallHook: HookSystem<SliceMachineHooks>[\"callHook\"];\n\thooksForOwner: HookSystem<SliceMachineHooks>[\"hooksForOwner\"];\n\thooksForType: HookSystem<SliceMachineHooks>[\"hooksForType\"];\n\tcreateScope: HookSystem<SliceMachineHooks>[\"createScope\"];\n\n\tconstructor({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins = {},\n\t}: SliceMachinePluginRunnerConstructorArgs) {\n\t\tthis._project = project;\n\t\tthis._hookSystem = hookSystem;\n\t\tthis._nativePlugins = nativePlugins;\n\n\t\tthis.rawActions = createSliceMachineActions(\n\t\t\tthis._project,\n\t\t\tthis._hookSystem,\n\t\t);\n\t\tthis.rawHelpers = createSliceMachineHelpers(this._project);\n\n\t\tthis.callHook = this._hookSystem.callHook.bind(this._hookSystem);\n\t\tthis.hooksForOwner = this._hookSystem.hooksForOwner.bind(this._hookSystem);\n\t\tthis.hooksForType = this._hookSystem.hooksForType.bind(this._hookSystem);\n\t\tthis.createScope = this._hookSystem.createScope.bind(this._hookSystem);\n\t}\n\n\tprivate async _loadPlugin(\n\t\tpluginRegistration: SliceMachineConfigPluginRegistration,\n\t): Promise<LoadedSliceMachinePlugin> {\n\t\t// Sanitize registration\n\t\tconst { resolve, options = {} } =\n\t\t\ttypeof pluginRegistration === \"object\" && \"resolve\" in pluginRegistration\n\t\t\t\t? pluginRegistration\n\t\t\t\t: { resolve: pluginRegistration };\n\n\t\tlet plugin: SliceMachinePlugin | undefined = undefined;\n\n\t\tif (typeof resolve === \"string\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t\ttry {\n\t\t\t\tconst noop = path.resolve(this._project.root, \"noop.js\");\n\n\t\t\t\tlet resolvedID = resolve;\n\n\t\t\t\t// Support Yarn PnP\n\t\t\t\tif (\n\t\t\t\t\tprocess.versions.pnp &&\n\t\t\t\t\t\"findPnpApi\" in _module &&\n\t\t\t\t\ttypeof _module.findPnpApi === \"function\"\n\t\t\t\t) {\n\t\t\t\t\tconst pnpApi = _module.findPnpApi(noop);\n\t\t\t\t\tif (pnpApi) {\n\t\t\t\t\t\tresolvedID = pnpApi.resolveRequest(resolve, noop);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst raw = await createRequire(noop)(resolvedID);\n\t\t\t\tplugin = raw.default || raw;\n\t\t\t} catch (error) {\n\t\t\t\t// Only log in development, but not during tests when a native plugin matches.\n\t\t\t\tif (\n\t\t\t\t\timport.meta.env.DEV &&\n\t\t\t\t\t!(import.meta.env.TEST && resolve in this._nativePlugins)\n\t\t\t\t) {\n\t\t\t\t\tconsole.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\t// If an installed plugin cannot be resolved, try loading a native plugin.\n\t\t\t\tplugin = this._nativePlugins[resolve];\n\t\t\t}\n\n\t\t\tif (!plugin) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Could not resolve plugin \\`${resolve}\\`. Check that it has been installed.`,\n\t\t\t\t);\n\t\t\t}\n\t\t} else {\n\t\t\tplugin = resolve;\n\t\t}\n\n\t\tif (!plugin) {\n\t\t\tthrow new Error(`Could not load plugin: \\`${resolve}\\``);\n\t\t}\n\n\t\tconst mergedOptions = defu(options, plugin.defaultOptions || {});\n\n\t\treturn {\n\t\t\t...plugin,\n\t\t\tresolve,\n\t\t\toptions: mergedOptions,\n\t\t};\n\t}\n\n\tprivate async _setupPlugin(\n\t\tplugin: LoadedSliceMachinePlugin,\n\t\tas: \"adapter\" | \"plugin\",\n\t): Promise<void> {\n\t\tconst context = createSliceMachineContext({\n\t\t\tactions: this.rawActions,\n\t\t\thelpers: this.rawHelpers,\n\t\t\tproject: this._project,\n\t\t\tplugin,\n\t\t});\n\t\tconst hookSystemScope =\n\t\t\tthis._hookSystem.createScope<SliceMachineHookExtraArgs>(\n\t\t\t\tplugin.meta.name,\n\t\t\t\t[context],\n\t\t\t);\n\n\t\t// Prevent plugins from hooking to adapter only hooks\n\t\tconst hook: typeof hookSystemScope.hook =\n\t\t\tas === \"adapter\"\n\t\t\t\t? hookSystemScope.hook\n\t\t\t\t: (type, hook, ...args) => {\n\t\t\t\t\t\tif (ADAPTER_ONLY_HOOKS.includes(type)) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn hookSystemScope.hook(type, hook, ...args);\n\t\t\t\t };\n\n\t\t// Run plugin setup with actions and context\n\t\ttry {\n\t\t\tawait plugin.setup({\n\t\t\t\t...context,\n\t\t\t\thook,\n\t\t\t\tunhook: hookSystemScope.unhook,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error.message}`,\n\t\t\t\t\t{ cause: error },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Plugin \\`${plugin.meta.name}\\` errored during setup: ${error}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate _validateAdapter(adapter: LoadedSliceMachinePlugin): void {\n\t\tconst hooks = this._hookSystem.hooksForOwner(adapter.meta.name);\n\t\tconst hookTypes = hooks.map((hook) => hook.meta.type);\n\n\t\tconst missingHooks = REQUIRED_ADAPTER_HOOKS.filter(\n\t\t\t(requiredHookType) => !hookTypes.includes(requiredHookType),\n\t\t);\n\n\t\tif (missingHooks.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Adapter \\`${\n\t\t\t\t\tadapter.meta.name\n\t\t\t\t}\\` is missing hooks: \\`${missingHooks.join(\"`, `\")}\\``,\n\t\t\t);\n\t\t}\n\t}\n\n\tasync init(): Promise<void> {\n\t\tconst [adapter, ...plugins] = await Promise.all(\n\t\t\t[\n\t\t\t\tthis._project.config.adapter,\n\t\t\t\t...(this._project.config.plugins ?? []),\n\t\t\t].map((pluginRegistration) => this._loadPlugin(pluginRegistration)),\n\t\t);\n\n\t\tawait Promise.all([\n\t\t\tthis._setupPlugin(adapter, \"adapter\"),\n\t\t\t...plugins.map((plugin) => this._setupPlugin(plugin, \"plugin\")),\n\t\t]);\n\n\t\tthis._validateAdapter(adapter);\n\t}\n}\n\ntype CreateSliceMachinePluginRunnerArgs = {\n\tproject: SliceMachineProject;\n\tnativePlugins?: Record<string, SliceMachinePlugin>;\n};\n\n/**\n * @internal\n */\nexport const createSliceMachinePluginRunner = ({\n\tproject,\n\tnativePlugins,\n}: CreateSliceMachinePluginRunnerArgs): SliceMachinePluginRunner => {\n\tconst hookSystem = createSliceMachineHookSystem();\n\n\treturn new SliceMachinePluginRunner({\n\t\tproject,\n\t\thookSystem,\n\t\tnativePlugins,\n\t});\n};\n"],"names":["hook"],"mappings":";;;;;;;;;;AA+BO,MAAM,yBAAkD;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;;AAKM,MAAM,qBAA8C;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA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,KAAK,YAAY,cAAc,QAAQ,KAAK,IAAI;AAC9D,UAAM,YAAY,MAAM,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI;AAEpD,UAAM,eAAe,uBAAuB,OAC3C,CAAC,qBAAqB,CAAC,UAAU,SAAS,gBAAgB,CAAC;AAG5D,QAAI,aAAa,QAAQ;AACxB,YAAM,IAAI,MACT,aACC,QAAQ,KAAK,IACd,0BAA0B,aAAa,KAAK,MAAM,CAAC,IAAI;AAAA,IAEzD;AAAA,EACD;AAAA,EAEA,MAAM,OAAI;AACT,UAAM,CAAC,SAAS,GAAG,OAAO,IAAI,MAAM,QAAQ,IAC3C;AAAA,MACC,KAAK,SAAS,OAAO;AAAA,MACrB,GAAI,KAAK,SAAS,OAAO,WAAW,CAAA;AAAA,IAAA,EACnC,IAAI,CAAC,uBAAuB,KAAK,YAAY,kBAAkB,CAAC,CAAC;AAGpE,UAAM,QAAQ,IAAI;AAAA,MACjB,KAAK,aAAa,SAAS,SAAS;AAAA,MACpC,GAAG,QAAQ,IAAI,CAAC,WAAW,KAAK,aAAa,QAAQ,QAAQ,CAAC;AAAA,IAAA,CAC9D;AAED,SAAK,iBAAiB,OAAO;AAAA,EAC9B;AACA;AAUM,MAAM,iCAAiC,CAAC,EAC9C,SACA,oBACkE;AAClE,QAAM,aAAa,6BAAA;AAEnB,SAAO,IAAI,yBAAyB;AAAA,IACnC;AAAA,IACA;AAAA,IACA;AAAA,EAAA,CACA;AACF;"}
package/dist/fs/index.cjs CHANGED
@@ -28,6 +28,7 @@ const writeCustomTypeModel = require("./writeCustomTypeModel.cjs");
28
28
  const readCustomTypeFile = require("./readCustomTypeFile.cjs");
29
29
  const readCustomTypeModel = require("./readCustomTypeModel.cjs");
30
30
  const renameCustomType = require("./renameCustomType.cjs");
31
+ const updateCustomTypeRoute = require("./updateCustomTypeRoute.cjs");
31
32
  const deleteCustomTypeFile = require("./deleteCustomTypeFile.cjs");
32
33
  const deleteCustomTypeDirectory = require("./deleteCustomTypeDirectory.cjs");
33
34
  const readSliceTemplateLibrary = require("./readSliceTemplateLibrary.cjs");
@@ -59,6 +60,7 @@ exports.writeCustomTypeModel = writeCustomTypeModel.writeCustomTypeModel;
59
60
  exports.readCustomTypeFile = readCustomTypeFile.readCustomTypeFile;
60
61
  exports.readCustomTypeModel = readCustomTypeModel.readCustomTypeModel;
61
62
  exports.renameCustomType = renameCustomType.renameCustomType;
63
+ exports.updateCustomTypeRoute = updateCustomTypeRoute.updateCustomTypeRoute;
62
64
  exports.deleteCustomTypeFile = deleteCustomTypeFile.deleteCustomTypeFile;
63
65
  exports.deleteCustomTypeDirectory = deleteCustomTypeDirectory.deleteCustomTypeDirectory;
64
66
  exports.readSliceTemplateLibrary = readSliceTemplateLibrary.readSliceTemplateLibrary;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -53,6 +53,8 @@ export { readCustomTypeModel } from "./readCustomTypeModel";
53
53
  export type { ReadCustomTypeModelArgs, ReadCustomTypeModelReturnType, } from "./readCustomTypeModel";
54
54
  export { renameCustomType } from "./renameCustomType";
55
55
  export type { RenameCustomTypeArgs } from "./renameCustomType";
56
+ export { updateCustomTypeRoute } from "./updateCustomTypeRoute";
57
+ export type { UpdateCustomTypeRouteArgs } from "./updateCustomTypeRoute";
56
58
  export { deleteCustomTypeFile } from "./deleteCustomTypeFile";
57
59
  export type { DeleteCustomTypeFileArgs } from "./deleteCustomTypeFile";
58
60
  export { deleteCustomTypeDirectory } from "./deleteCustomTypeDirectory";
package/dist/fs/index.js CHANGED
@@ -26,6 +26,7 @@ import { writeCustomTypeModel } from "./writeCustomTypeModel.js";
26
26
  import { readCustomTypeFile } from "./readCustomTypeFile.js";
27
27
  import { readCustomTypeModel } from "./readCustomTypeModel.js";
28
28
  import { renameCustomType } from "./renameCustomType.js";
29
+ import { updateCustomTypeRoute } from "./updateCustomTypeRoute.js";
29
30
  import { deleteCustomTypeFile } from "./deleteCustomTypeFile.js";
30
31
  import { deleteCustomTypeDirectory } from "./deleteCustomTypeDirectory.js";
31
32
  import { readSliceTemplateLibrary } from "./readSliceTemplateLibrary.js";
@@ -54,6 +55,7 @@ export {
54
55
  readSliceTemplateLibrary,
55
56
  renameCustomType,
56
57
  renameSlice,
58
+ updateCustomTypeRoute,
57
59
  upsertGlobalTypeScriptTypes,
58
60
  writeCustomTypeFile,
59
61
  writeCustomTypeModel,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const writeCustomTypeModel = require("./writeCustomTypeModel.cjs");
4
+ const updateCustomTypeRoute = async (args) => {
5
+ await writeCustomTypeModel.writeCustomTypeModel(args);
6
+ };
7
+ exports.updateCustomTypeRoute = updateCustomTypeRoute;
8
+ //# sourceMappingURL=updateCustomTypeRoute.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateCustomTypeRoute.cjs","sources":["../../../src/fs/updateCustomTypeRoute.ts"],"sourcesContent":["import {\n\twriteCustomTypeModel,\n\tWriteCustomTypeModelArgs,\n} from \"./writeCustomTypeModel\";\n\nexport type UpdateCustomTypeRouteArgs = WriteCustomTypeModelArgs;\n\nexport const updateCustomTypeRoute = async (\n\targs: UpdateCustomTypeRouteArgs,\n): Promise<void> => {\n\tawait writeCustomTypeModel(args);\n};\n"],"names":["writeCustomTypeModel"],"mappings":";;;AAOO,MAAM,wBAAwB,OACpC,SACkB;AAClB,QAAMA,qBAAAA,qBAAqB,IAAI;AAChC;;"}
@@ -0,0 +1,3 @@
1
+ import { WriteCustomTypeModelArgs } from "./writeCustomTypeModel";
2
+ export type UpdateCustomTypeRouteArgs = WriteCustomTypeModelArgs;
3
+ export declare const updateCustomTypeRoute: (args: UpdateCustomTypeRouteArgs) => Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { writeCustomTypeModel } from "./writeCustomTypeModel.js";
2
+ const updateCustomTypeRoute = async (args) => {
3
+ await writeCustomTypeModel(args);
4
+ };
5
+ export {
6
+ updateCustomTypeRoute
7
+ };
8
+ //# sourceMappingURL=updateCustomTypeRoute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"updateCustomTypeRoute.js","sources":["../../../src/fs/updateCustomTypeRoute.ts"],"sourcesContent":["import {\n\twriteCustomTypeModel,\n\tWriteCustomTypeModelArgs,\n} from \"./writeCustomTypeModel\";\n\nexport type UpdateCustomTypeRouteArgs = WriteCustomTypeModelArgs;\n\nexport const updateCustomTypeRoute = async (\n\targs: UpdateCustomTypeRouteArgs,\n): Promise<void> => {\n\tawait writeCustomTypeModel(args);\n};\n"],"names":[],"mappings":";AAOO,MAAM,wBAAwB,OACpC,SACkB;AAClB,QAAM,qBAAqB,IAAI;AAChC;"}
@@ -0,0 +1,29 @@
1
+ import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
2
+ import type { ExtendSliceMachineHook, SliceMachinePluginOptions, SliceMachineHook } from "../types";
3
+ /**
4
+ * Data provided to `custom-type:update-route` hook handlers.
5
+ */
6
+ export type CustomTypeUpdateRouteHookData = {
7
+ model: CustomType;
8
+ };
9
+ /**
10
+ * Return value for `custom-type:update-route` hook handlers.
11
+ */
12
+ export type CustomTypeUpdateRouteHookReturnType = void;
13
+ /**
14
+ * Base version of a `custom-type:update-route` hook handler without plugin
15
+ * runner context.
16
+ *
17
+ * @internal
18
+ */
19
+ export type CustomTypeUpdateRouteHookBase = SliceMachineHook<CustomTypeUpdateRouteHookData, CustomTypeUpdateRouteHookReturnType>;
20
+ /**
21
+ * Handler for the `custom-type:update-route` hook. The hook is called when a
22
+ * Custom Type route is updated.
23
+ *
24
+ * `custom-type:update-route` is not called the first time a Custom Type is
25
+ * updated.
26
+ *
27
+ * @typeParam TPluginOptions - User-provided options for the hook's plugin.
28
+ */
29
+ export type CustomTypeUpdateRouteHook<TPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions> = ExtendSliceMachineHook<CustomTypeUpdateRouteHookBase, TPluginOptions>;
package/dist/index.d.ts CHANGED
@@ -22,6 +22,7 @@ export type { CustomTypeAssetReadHook, CustomTypeAssetReadHookData, CustomTypeAs
22
22
  export type { CustomTypeCreateHook, CustomTypeCreateHookData, CustomTypeCreateHookReturnType, } from "./hooks/customType-create";
23
23
  export type { CustomTypeUpdateHook, CustomTypeUpdateHookData, CustomTypeUpdateHookReturnType, } from "./hooks/customType-update";
24
24
  export type { CustomTypeRenameHook, CustomTypeRenameHookData, CustomTypeRenameHookReturnType, } from "./hooks/customType-rename";
25
+ export type { CustomTypeUpdateRouteHook, CustomTypeUpdateRouteHookData, CustomTypeUpdateRouteHookReturnType, } from "./hooks/customType-update-route";
25
26
  export type { CustomTypeDeleteHook, CustomTypeDeleteHookData, CustomTypeDeleteHookReturnType, } from "./hooks/customType-delete";
26
27
  export type { CustomTypeReadHook, CustomTypeReadHookData, CustomTypeReadHookReturnType, } from "./hooks/customType-read";
27
28
  export type { CustomTypeLibraryReadHook, CustomTypeLibraryReadHookData, CustomTypeLibraryReadHookReturnType, } from "./hooks/customTypeLibrary-read";
package/dist/types.cjs CHANGED
@@ -13,6 +13,7 @@ const SliceMachineHookType = {
13
13
  customType_create: "custom-type:create",
14
14
  customType_update: "custom-type:update",
15
15
  customType_rename: "custom-type:rename",
16
+ customType_update_route: "custom-type:update-route",
16
17
  customType_delete: "custom-type:delete",
17
18
  customType_read: "custom-type:read",
18
19
  customType_asset_update: "custom-type:asset:update",
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":";;AA0IO,MAAM,uBAAuB;AAAA,EACnC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EAEnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EAEd,cAAc;AAAA,EACd,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,OAAO;;;"}
1
+ {"version":3,"file":"types.cjs","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\nimport { CustomTypeUpdateRouteHookBase } from \"./hooks/customType-update-route\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_update_route: \"custom-type:update-route\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_update_route]: Hook<CustomTypeUpdateRouteHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":";;AA2IO,MAAM,uBAAuB;AAAA,EACnC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EAEnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EAEd,cAAc;AAAA,EACd,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,OAAO;;;"}
package/dist/types.d.ts CHANGED
@@ -26,6 +26,7 @@ import { DocumentationReadHookBase } from "./hooks/documentation-read";
26
26
  import { SliceTemplateLibraryReadHookBase } from "./hooks/sliceTemplateLibrary-read";
27
27
  import { ProjectEnvironmentReadHookBase } from "./hooks/project-environment-read";
28
28
  import { ProjectEnvironmentUpdateHookBase } from "./hooks/project-environment-update";
29
+ import { CustomTypeUpdateRouteHookBase } from "./hooks/customType-update-route";
29
30
  /**
30
31
  * A value optionally wrapped in a `PromiseLike`.
31
32
  *
@@ -116,6 +117,7 @@ export declare const SliceMachineHookType: {
116
117
  readonly customType_create: "custom-type:create";
117
118
  readonly customType_update: "custom-type:update";
118
119
  readonly customType_rename: "custom-type:rename";
120
+ readonly customType_update_route: "custom-type:update-route";
119
121
  readonly customType_delete: "custom-type:delete";
120
122
  readonly customType_read: "custom-type:read";
121
123
  readonly customType_asset_update: "custom-type:asset:update";
@@ -149,6 +151,7 @@ export type SliceMachineHooks = {
149
151
  [SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;
150
152
  [SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;
151
153
  [SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;
154
+ [SliceMachineHookType.customType_update_route]: Hook<CustomTypeUpdateRouteHookBase>;
152
155
  [SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;
153
156
  [SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;
154
157
  [SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;
package/dist/types.js CHANGED
@@ -11,6 +11,7 @@ const SliceMachineHookType = {
11
11
  customType_create: "custom-type:create",
12
12
  customType_update: "custom-type:update",
13
13
  customType_rename: "custom-type:rename",
14
+ customType_update_route: "custom-type:update-route",
14
15
  customType_delete: "custom-type:delete",
15
16
  customType_read: "custom-type:read",
16
17
  customType_asset_update: "custom-type:asset:update",
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":"AA0IO,MAAM,uBAAuB;AAAA,EACnC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EAEnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EAEd,cAAc;AAAA,EACd,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,OAAO;;"}
1
+ {"version":3,"file":"types.js","sources":["../../src/types.ts"],"sourcesContent":["import { SliceMachineContext } from \"./createSliceMachineContext\";\nimport { SliceMachinePlugin } from \"./defineSliceMachinePlugin\";\nimport { Hook } from \"./lib/HookSystem\";\n\nimport { ProjectInitHookBase } from \"./hooks/project-init\";\nimport { CustomTypeAssetDeleteHookBase } from \"./hooks/customType-asset-delete\";\nimport { CustomTypeAssetReadHookBase } from \"./hooks/customType-asset-read\";\nimport { CustomTypeAssetUpdateHookBase } from \"./hooks/customType-asset-update\";\nimport { CustomTypeCreateHookBase } from \"./hooks/customType-create\";\nimport { CustomTypeDeleteHookBase } from \"./hooks/customType-delete\";\nimport { CustomTypeLibraryReadHookBase } from \"./hooks/customTypeLibrary-read\";\nimport { CustomTypeReadHookBase } from \"./hooks/customType-read\";\nimport { CustomTypeRenameHookBase } from \"./hooks/customType-rename\";\nimport { CustomTypeUpdateHookBase } from \"./hooks/customType-update\";\nimport { DebugHookBase } from \"./hooks/debug\";\nimport { SliceAssetDeleteHookBase } from \"./hooks/slice-asset-delete\";\nimport { SliceAssetReadHookBase } from \"./hooks/slice-asset-read\";\nimport { SliceAssetUpdateHookBase } from \"./hooks/slice-asset-update\";\nimport { SliceCreateHookBase } from \"./hooks/slice-create\";\nimport { SliceDeleteHookBase } from \"./hooks/slice-delete\";\nimport { SliceLibraryReadHookBase } from \"./hooks/sliceLibrary-read\";\nimport { SliceReadHookBase } from \"./hooks/slice-read\";\nimport { SliceRenameHookBase } from \"./hooks/slice-rename\";\nimport { SliceUpdateHookBase } from \"./hooks/slice-update\";\nimport { SnippetReadHookBase } from \"./hooks/snippet-read\";\nimport { DocumentationReadHookBase } from \"./hooks/documentation-read\";\n\nimport { SliceTemplateLibraryReadHookBase } from \"./hooks/sliceTemplateLibrary-read\";\nimport { ProjectEnvironmentReadHookBase } from \"./hooks/project-environment-read\";\nimport { ProjectEnvironmentUpdateHookBase } from \"./hooks/project-environment-update\";\nimport { CustomTypeUpdateRouteHookBase } from \"./hooks/customType-update-route\";\n\n/**\n * A value optionally wrapped in a `PromiseLike`.\n *\n * @typeParam T - The value that can optionally be wrapped.\n */\nexport type Promisable<T> = T | PromiseLike<T>;\n\n/**\n * A generic type for a user-provided plugin options. Prefer using a\n * plugin-specific type over this type.\n */\nexport type SliceMachinePluginOptions = Record<string, unknown>;\n\n/**\n * A string, object, or instance representing a registered plugin.\n *\n * @typeParam TPluginOptions - User-provided options for the plugin.\n */\nexport type SliceMachineConfigPluginRegistration<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> =\n\t| string\n\t| SliceMachinePlugin\n\t| {\n\t\t\tresolve: string | SliceMachinePlugin;\n\t\t\toptions?: TPluginOptions;\n\t };\n\n/**\n * Slice Machine configuration from `slicemachine.config.js`.\n */\nexport type SliceMachineConfig = {\n\t// TODO: Can we make `apiEndpoint` optional?\n\tapiEndpoint?: string;\n\t// NOTE: This is a new property.\n\trepositoryName: string;\n\tlocalSliceSimulatorURL?: string;\n\tlibraries?: string[];\n\tadapter: SliceMachineConfigPluginRegistration;\n\tplugins?: SliceMachineConfigPluginRegistration[];\n\tlabs?: { legacySliceUpgrader?: boolean };\n};\n\n/**\n * Slice Machine project metadata.\n */\nexport type SliceMachineProject = {\n\t/**\n\t * An absolute path to project root.\n\t */\n\troot: string;\n\t/**\n\t * Slice Machine `slicemachine.config.json` content, validated.\n\t */\n\tconfig: SliceMachineConfig;\n};\n\n/**\n * A Slice Library's metadata.\n */\nexport type SliceLibrary = {\n\tid: string;\n};\n\n// ============================================================================\n//\n// # HOOK TYPES\n//\n// ============================================================================\n\n/**\n * A hook handler.\n */\nexport type SliceMachineHook<TData, TReturn> = (\n\tdata: TData,\n) => Promisable<TReturn>;\n\n/**\n * Extra arguments provided to hooks when called.\n *\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type SliceMachineHookExtraArgs<\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = [context: SliceMachineContext<TPluginOptions>];\n\n/**\n * Utility type to extend a hook handler's type with Slice Machine-specific\n * extra arguments.\n *\n * @typeParam THook - Hook handler to extend.\n * @typeParam TPluginOptions - User-provided options for the hook's plugin.\n */\nexport type ExtendSliceMachineHook<\n\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\tTHook extends SliceMachineHook<any, any>,\n\tTPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,\n> = (\n\t...args: [\n\t\t...args: Parameters<THook>,\n\t\t...extraArgs: SliceMachineHookExtraArgs<TPluginOptions>,\n\t]\n) => ReturnType<THook>;\n\n/**\n * Hook types.\n */\nexport const SliceMachineHookType = {\n\tslice_create: \"slice:create\",\n\tslice_update: \"slice:update\",\n\tslice_rename: \"slice:rename\",\n\tslice_delete: \"slice:delete\",\n\tslice_read: \"slice:read\",\n\tslice_asset_update: \"slice:asset:update\",\n\tslice_asset_delete: \"slice:asset:delete\",\n\tslice_asset_read: \"slice:asset:read\",\n\tsliceLibrary_read: \"slice-library:read\",\n\n\tcustomType_create: \"custom-type:create\",\n\tcustomType_update: \"custom-type:update\",\n\tcustomType_rename: \"custom-type:rename\",\n\tcustomType_update_route: \"custom-type:update-route\",\n\tcustomType_delete: \"custom-type:delete\",\n\tcustomType_read: \"custom-type:read\",\n\tcustomType_asset_update: \"custom-type:asset:update\",\n\tcustomType_asset_delete: \"custom-type:asset:delete\",\n\tcustomType_asset_read: \"custom-type:asset:read\",\n\tcustomTypeLibrary_read: \"custom-type-library:read\",\n\tdocumentation_read: \"documentation:read\",\n\tsliceTemplateLibrary_read: \"slice-template-library:read\",\n\n\tsnippet_read: \"snippet:read\",\n\n\tproject_init: \"project:init\",\n\tproject_environment_read: \"project:environment:read\",\n\tproject_environment_update: \"project:environment:update\",\n\n\tdebug: \"debug\",\n} as const;\n\n/**\n * Hook types.\n */\nexport type SliceMachineHookTypes =\n\t(typeof SliceMachineHookType)[keyof typeof SliceMachineHookType];\n\n/**\n * Slice Machine-specific hook handlers.\n */\nexport type SliceMachineHooks = {\n\t// Slices\n\t[SliceMachineHookType.slice_create]: Hook<SliceCreateHookBase>;\n\t[SliceMachineHookType.slice_update]: Hook<SliceUpdateHookBase>;\n\t[SliceMachineHookType.slice_rename]: Hook<SliceRenameHookBase>;\n\t[SliceMachineHookType.slice_delete]: Hook<SliceDeleteHookBase>;\n\t[SliceMachineHookType.slice_read]: Hook<SliceReadHookBase>;\n\t[SliceMachineHookType.slice_asset_update]: Hook<SliceAssetUpdateHookBase>;\n\t[SliceMachineHookType.slice_asset_delete]: Hook<SliceAssetDeleteHookBase>;\n\t[SliceMachineHookType.slice_asset_read]: Hook<SliceAssetReadHookBase>;\n\n\t// Slice Libraries\n\t[SliceMachineHookType.sliceLibrary_read]: Hook<SliceLibraryReadHookBase>;\n\n\t// Custom Types\n\t[SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;\n\t[SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;\n\t[SliceMachineHookType.customType_update_route]: Hook<CustomTypeUpdateRouteHookBase>;\n\t[SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;\n\t[SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;\n\t[SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;\n\t[SliceMachineHookType.customType_asset_update]: Hook<CustomTypeAssetUpdateHookBase>;\n\t[SliceMachineHookType.customType_asset_delete]: Hook<CustomTypeAssetDeleteHookBase>;\n\t[SliceMachineHookType.customType_asset_read]: Hook<CustomTypeAssetReadHookBase>;\n\n\t// Custom Type Libraries\n\t[SliceMachineHookType.customTypeLibrary_read]: Hook<CustomTypeLibraryReadHookBase>;\n\n\t// Snippets\n\t[SliceMachineHookType.snippet_read]: Hook<SnippetReadHookBase>;\n\n\t// Documentation\n\t[SliceMachineHookType.documentation_read]: Hook<DocumentationReadHookBase>;\n\n\t// Project\n\t[SliceMachineHookType.project_init]: Hook<ProjectInitHookBase>;\n\t[SliceMachineHookType.project_environment_read]: Hook<ProjectEnvironmentReadHookBase>;\n\t[SliceMachineHookType.project_environment_update]: Hook<ProjectEnvironmentUpdateHookBase>;\n\n\t// Debug\n\t[SliceMachineHookType.debug]: Hook<DebugHookBase>;\n\n\t// Slice templates\n\t[SliceMachineHookType.sliceTemplateLibrary_read]: Hook<SliceTemplateLibraryReadHookBase>;\n};\n"],"names":[],"mappings":"AA2IO,MAAM,uBAAuB;AAAA,EACnC,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,cAAc;AAAA,EACd,YAAY;AAAA,EACZ,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,mBAAmB;AAAA,EAEnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,mBAAmB;AAAA,EACnB,yBAAyB;AAAA,EACzB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,yBAAyB;AAAA,EACzB,yBAAyB;AAAA,EACzB,uBAAuB;AAAA,EACvB,wBAAwB;AAAA,EACxB,oBAAoB;AAAA,EACpB,2BAA2B;AAAA,EAE3B,cAAc;AAAA,EAEd,cAAc;AAAA,EACd,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAE5B,OAAO;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slicemachine/plugin-kit",
3
- "version": "0.4.83-beta.3",
3
+ "version": "0.4.84-alpha.lg-page-routes.1",
4
4
  "description": "A set of helpers to develop and run Slice Machine plugins",
5
5
  "keywords": [
6
6
  "typescript",
@@ -104,5 +104,5 @@
104
104
  "publishConfig": {
105
105
  "access": "public"
106
106
  },
107
- "stableVersion": "0.4.82"
107
+ "stableVersion": "0.4.83"
108
108
  }
@@ -42,6 +42,7 @@ export const REQUIRED_ADAPTER_HOOKS: SliceMachineHookTypes[] = [
42
42
  "custom-type:create",
43
43
  "custom-type:read",
44
44
  "custom-type:rename",
45
+ "custom-type:update-route",
45
46
  "custom-type:delete",
46
47
  "custom-type:update",
47
48
  "custom-type:asset:update",
package/src/fs/index.ts CHANGED
@@ -114,6 +114,9 @@ export type {
114
114
  export { renameCustomType } from "./renameCustomType";
115
115
  export type { RenameCustomTypeArgs } from "./renameCustomType";
116
116
 
117
+ export { updateCustomTypeRoute } from "./updateCustomTypeRoute";
118
+ export type { UpdateCustomTypeRouteArgs } from "./updateCustomTypeRoute";
119
+
117
120
  export { deleteCustomTypeFile } from "./deleteCustomTypeFile";
118
121
  export type { DeleteCustomTypeFileArgs } from "./deleteCustomTypeFile";
119
122
 
@@ -0,0 +1,12 @@
1
+ import {
2
+ writeCustomTypeModel,
3
+ WriteCustomTypeModelArgs,
4
+ } from "./writeCustomTypeModel";
5
+
6
+ export type UpdateCustomTypeRouteArgs = WriteCustomTypeModelArgs;
7
+
8
+ export const updateCustomTypeRoute = async (
9
+ args: UpdateCustomTypeRouteArgs,
10
+ ): Promise<void> => {
11
+ await writeCustomTypeModel(args);
12
+ };
@@ -0,0 +1,43 @@
1
+ import type { CustomType } from "@prismicio/types-internal/lib/customtypes";
2
+
3
+ import type {
4
+ ExtendSliceMachineHook,
5
+ SliceMachinePluginOptions,
6
+ SliceMachineHook,
7
+ } from "../types";
8
+
9
+ /**
10
+ * Data provided to `custom-type:update-route` hook handlers.
11
+ */
12
+ export type CustomTypeUpdateRouteHookData = {
13
+ model: CustomType;
14
+ };
15
+
16
+ /**
17
+ * Return value for `custom-type:update-route` hook handlers.
18
+ */
19
+ export type CustomTypeUpdateRouteHookReturnType = void;
20
+
21
+ /**
22
+ * Base version of a `custom-type:update-route` hook handler without plugin
23
+ * runner context.
24
+ *
25
+ * @internal
26
+ */
27
+ export type CustomTypeUpdateRouteHookBase = SliceMachineHook<
28
+ CustomTypeUpdateRouteHookData,
29
+ CustomTypeUpdateRouteHookReturnType
30
+ >;
31
+
32
+ /**
33
+ * Handler for the `custom-type:update-route` hook. The hook is called when a
34
+ * Custom Type route is updated.
35
+ *
36
+ * `custom-type:update-route` is not called the first time a Custom Type is
37
+ * updated.
38
+ *
39
+ * @typeParam TPluginOptions - User-provided options for the hook's plugin.
40
+ */
41
+ export type CustomTypeUpdateRouteHook<
42
+ TPluginOptions extends SliceMachinePluginOptions = SliceMachinePluginOptions,
43
+ > = ExtendSliceMachineHook<CustomTypeUpdateRouteHookBase, TPluginOptions>;
package/src/index.ts CHANGED
@@ -140,6 +140,13 @@ export type {
140
140
  CustomTypeRenameHookReturnType,
141
141
  } from "./hooks/customType-rename";
142
142
 
143
+ // custom-type:update-route
144
+ export type {
145
+ CustomTypeUpdateRouteHook,
146
+ CustomTypeUpdateRouteHookData,
147
+ CustomTypeUpdateRouteHookReturnType,
148
+ } from "./hooks/customType-update-route";
149
+
143
150
  // custom-type:delete
144
151
  export type {
145
152
  CustomTypeDeleteHook,
package/src/types.ts CHANGED
@@ -28,6 +28,7 @@ import { DocumentationReadHookBase } from "./hooks/documentation-read";
28
28
  import { SliceTemplateLibraryReadHookBase } from "./hooks/sliceTemplateLibrary-read";
29
29
  import { ProjectEnvironmentReadHookBase } from "./hooks/project-environment-read";
30
30
  import { ProjectEnvironmentUpdateHookBase } from "./hooks/project-environment-update";
31
+ import { CustomTypeUpdateRouteHookBase } from "./hooks/customType-update-route";
31
32
 
32
33
  /**
33
34
  * A value optionally wrapped in a `PromiseLike`.
@@ -150,6 +151,7 @@ export const SliceMachineHookType = {
150
151
  customType_create: "custom-type:create",
151
152
  customType_update: "custom-type:update",
152
153
  customType_rename: "custom-type:rename",
154
+ customType_update_route: "custom-type:update-route",
153
155
  customType_delete: "custom-type:delete",
154
156
  customType_read: "custom-type:read",
155
157
  customType_asset_update: "custom-type:asset:update",
@@ -194,6 +196,7 @@ export type SliceMachineHooks = {
194
196
  // Custom Types
195
197
  [SliceMachineHookType.customType_create]: Hook<CustomTypeCreateHookBase>;
196
198
  [SliceMachineHookType.customType_update]: Hook<CustomTypeUpdateHookBase>;
199
+ [SliceMachineHookType.customType_update_route]: Hook<CustomTypeUpdateRouteHookBase>;
197
200
  [SliceMachineHookType.customType_rename]: Hook<CustomTypeRenameHookBase>;
198
201
  [SliceMachineHookType.customType_delete]: Hook<CustomTypeDeleteHookBase>;
199
202
  [SliceMachineHookType.customType_read]: Hook<CustomTypeReadHookBase>;