@adonis-agora/durable 0.31.1 → 0.31.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @adonis-agora/durable
2
2
 
3
+ ## 0.31.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#100](https://github.com/DavideCarvalho/adonis-agora-durable/pull/100) [`b2297e2`](https://github.com/DavideCarvalho/adonis-agora-durable/commit/b2297e2d5f567ab5b0b3d707457c68d6c596a668) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `node ace configure` now writes the `#workflows/*` and `#steps/*` subpath imports into the app's `package.json`.
8
+
9
+ The barrels the assembler hooks generate import each module by alias (`#workflows/foo_workflow`), the way `@adonisjs/core`'s controllers barrel uses `#controllers/*`. The difference is that `#controllers/*` ships in the app skeleton and `#workflows/*` does not — so `configure` wired up barrels that named a specifier Node cannot resolve, and the app died at boot with `ERR_PACKAGE_IMPORT_NOT_DEFINED`, after a build that reported success.
10
+
11
+ Existing apps: add these to `package.json` → `imports` (or re-run `configure`, which is now a no-op when they are already present and never overwrites an alias you point elsewhere):
12
+
13
+ ```json
14
+ "#workflows/*": "./app/workflows/*.js",
15
+ "#steps/*": "./app/steps/*.js"
16
+ ```
17
+
3
18
  ## 0.31.1
4
19
 
5
20
  ### Patch Changes
@@ -10,8 +10,11 @@ import type Configure from '@adonisjs/core/commands/configure';
10
10
  * and `app/steps` barrels at build/dev time (the provider imports them instead
11
11
  * of scanning at runtime; each falls back to the runtime scan when its barrel
12
12
  * is absent);
13
- * 5. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
14
- * 6. publishes the Lucid migrations for the optional `lucid` store and `db`
13
+ * 5. adds the `#workflows/*` and `#steps/*` subpath imports to the app's `package.json`,
14
+ * which the generated barrels import through (without them the app boots into
15
+ * `ERR_PACKAGE_IMPORT_NOT_DEFINED`);
16
+ * 6. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
17
+ * 7. publishes the Lucid migrations for the optional `lucid` store and `db`
15
18
  * transport drivers (run `node ace migration:run`, and delete the transport
16
19
  * migration if you don't use the `db` transport).
17
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAC;AAG/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,iBAqBjD"}
1
+ {"version":3,"file":"configure.d.ts","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,SAAS,MAAM,mCAAmC,CAAC;AAI/D;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,SAAS,CAAC,OAAO,EAAE,SAAS,iBAuBjD"}
package/dist/configure.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { readFile, writeFile } from 'node:fs/promises';
2
+ import { mergeSubpathImports } from './src/configure-imports.js';
1
3
  import { stubsRoot } from './stubs/main.js';
2
4
  /**
3
5
  * `node ace configure @adonis-agora/durable` — auto-wires the package:
@@ -10,8 +12,11 @@ import { stubsRoot } from './stubs/main.js';
10
12
  * and `app/steps` barrels at build/dev time (the provider imports them instead
11
13
  * of scanning at runtime; each falls back to the runtime scan when its barrel
12
14
  * is absent);
13
- * 5. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
14
- * 6. publishes the Lucid migrations for the optional `lucid` store and `db`
15
+ * 5. adds the `#workflows/*` and `#steps/*` subpath imports to the app's `package.json`,
16
+ * which the generated barrels import through (without them the app boots into
17
+ * `ERR_PACKAGE_IMPORT_NOT_DEFINED`);
18
+ * 6. publishes `config/durable.ts` + `config/durable_dashboard.ts`;
19
+ * 7. publishes the Lucid migrations for the optional `lucid` store and `db`
15
20
  * transport drivers (run `node ace migration:run`, and delete the transport
16
21
  * migration if you don't use the `db` transport).
17
22
  */
@@ -26,9 +31,35 @@ export async function configure(command) {
26
31
  rcFile.addAssemblerHook('init', '@adonis-agora/durable/hooks/workflows');
27
32
  rcFile.addAssemblerHook('init', '@adonis-agora/durable/hooks/steps');
28
33
  });
34
+ await addSubpathImports(command);
29
35
  await codemods.makeUsingStub(stubsRoot, 'config/durable.stub', {});
30
36
  await codemods.makeUsingStub(stubsRoot, 'config/durable_dashboard.stub', {});
31
37
  await codemods.makeUsingStub(stubsRoot, 'database/migrations/create_durable_tables.stub', {});
32
38
  await codemods.makeUsingStub(stubsRoot, 'database/migrations/create_durable_transport_tables.stub', {});
33
39
  }
40
+ /**
41
+ * Add the subpath imports the generated barrels resolve through. There is no codemod for the
42
+ * `imports` map, so this edits `package.json` directly — and only when something is missing, so a
43
+ * second `configure` run neither rewrites the file nor logs a change it did not make.
44
+ */
45
+ async function addSubpathImports(command) {
46
+ const path = command.app.makePath('package.json');
47
+ let raw;
48
+ try {
49
+ raw = await readFile(path, 'utf-8');
50
+ }
51
+ catch {
52
+ command.logger.warning('could not read package.json — add "#workflows/*": "./app/workflows/*.js" and "#steps/*": "./app/steps/*.js" to its "imports" by hand');
53
+ return;
54
+ }
55
+ const pkg = JSON.parse(raw);
56
+ const { imports, added } = mergeSubpathImports(pkg.imports);
57
+ if (added.length === 0)
58
+ return;
59
+ pkg.imports = imports;
60
+ // Two-space JSON with a trailing newline: what `create-adonisjs` writes, so the diff stays to
61
+ // the added lines instead of reformatting the whole file.
62
+ await writeFile(path, `${JSON.stringify(pkg, null, 2)}\n`);
63
+ command.logger.action(`update package.json (imports: ${added.join(', ')})`).succeeded();
64
+ }
34
65
  //# sourceMappingURL=configure.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"configure.js","sourceRoot":"","sources":["../configure.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,OAAkB;IAChD,MAAM,QAAQ,GAAG,M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AI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAE/B,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;IACtB,8FAA8F;IAC9F,0DAA0D;IAC1D,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,iCAAiC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;AAC1F,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The Node subpath imports the generated barrels resolve through.
3
+ *
4
+ * The barrels the assembler hooks emit import each module by alias — `#workflows/foo_workflow` —
5
+ * exactly like `@adonisjs/core`'s controllers barrel uses `#controllers/*`. The difference is that
6
+ * `#controllers/*` ships in the app skeleton and `#workflows/*` does not, so without `configure`
7
+ * writing them the generated barrel names a specifier Node cannot resolve and the app dies at boot
8
+ * with `ERR_PACKAGE_IMPORT_NOT_DEFINED` — after a build that reported success.
9
+ *
10
+ * Keys and targets are kept in lockstep with the hooks' `importAlias` / `source` defaults; the spec
11
+ * asserts that pairing so changing one without the other fails loudly instead of at a consumer's
12
+ * boot.
13
+ */
14
+ export declare const DURABLE_SUBPATH_IMPORTS: Readonly<Record<string, string>>;
15
+ /**
16
+ * Merge {@link DURABLE_SUBPATH_IMPORTS} into an app's `package.json` `imports` map.
17
+ *
18
+ * Never overwrites an entry the app already defines — an app that points `#workflows/*` somewhere
19
+ * else made that choice deliberately, and `configure` is not the place to overrule it. Returns the
20
+ * merged map plus the keys actually added, so the caller can skip the write (and the log line) when
21
+ * there is nothing to do, making a re-run of `configure` a no-op.
22
+ */
23
+ export declare function mergeSubpathImports(existing: Record<string, string> | undefined): {
24
+ imports: Record<string, string>;
25
+ added: string[];
26
+ };
27
+ //# sourceMappingURL=configure-imports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure-imports.d.ts","sourceRoot":"","sources":["../../src/configure-imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGpE,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG;IACjF,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAWA"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * The Node subpath imports the generated barrels resolve through.
3
+ *
4
+ * The barrels the assembler hooks emit import each module by alias — `#workflows/foo_workflow` —
5
+ * exactly like `@adonisjs/core`'s controllers barrel uses `#controllers/*`. The difference is that
6
+ * `#controllers/*` ships in the app skeleton and `#workflows/*` does not, so without `configure`
7
+ * writing them the generated barrel names a specifier Node cannot resolve and the app dies at boot
8
+ * with `ERR_PACKAGE_IMPORT_NOT_DEFINED` — after a build that reported success.
9
+ *
10
+ * Keys and targets are kept in lockstep with the hooks' `importAlias` / `source` defaults; the spec
11
+ * asserts that pairing so changing one without the other fails loudly instead of at a consumer's
12
+ * boot.
13
+ */
14
+ export const DURABLE_SUBPATH_IMPORTS = {
15
+ '#workflows/*': './app/workflows/*.js',
16
+ '#steps/*': './app/steps/*.js',
17
+ };
18
+ /**
19
+ * Merge {@link DURABLE_SUBPATH_IMPORTS} into an app's `package.json` `imports` map.
20
+ *
21
+ * Never overwrites an entry the app already defines — an app that points `#workflows/*` somewhere
22
+ * else made that choice deliberately, and `configure` is not the place to overrule it. Returns the
23
+ * merged map plus the keys actually added, so the caller can skip the write (and the log line) when
24
+ * there is nothing to do, making a re-run of `configure` a no-op.
25
+ */
26
+ export function mergeSubpathImports(existing) {
27
+ const imports = { ...(existing ?? {}) };
28
+ const added = [];
29
+ for (const [key, target] of Object.entries(DURABLE_SUBPATH_IMPORTS)) {
30
+ if (key in imports)
31
+ continue;
32
+ imports[key] = target;
33
+ added.push(key);
34
+ }
35
+ return { imports, added };
36
+ }
37
+ //# sourceMappingURL=configure-imports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configure-imports.js","sourceRoot":"","sources":["../../src/configure-imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAqC;IACvE,cAAc,EAAE,sBAAsB;IACtC,UAAU,EAAE,kBAAkB;CAC/B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAA4C;IAI9E,MAAM,OAAO,GAAG,EAAE,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;IACxC,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC,EAAE,CAAC;QACpE,IAAI,GAAG,IAAI,OAAO;YAAE,SAAS;QAC7B,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;QACtB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAC5B,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /** Keep in sync with this package's `version` in package.json. */
2
- export declare const VERSION = "0.31.1";
2
+ export declare const VERSION = "0.31.2";
3
3
  export type { AccessDeniedInfo, AccessDeniedPageOptions, AccessDeniedReason, } from './access_denied_page.js';
4
4
  export { CONSOLE as ACCESS_DENIED_CONSOLE, escapeHtml, renderAccessDeniedPage, resolveAccessDeniedPage, } from './access_denied_page.js';
5
5
  export type { AuthMode, DashboardAuthOptions, LoginHook, LoginOutcome, ResolvedDashboardAuth, SessionHook, SessionOutcome, } from './auth.js';
@@ -1,5 +1,5 @@
1
1
  /** Keep in sync with this package's `version` in package.json. */
2
- export const VERSION = '0.31.1';
2
+ export const VERSION = '0.31.2';
3
3
  // The built-in "access denied" page (what a browser sees on a refused page navigation).
4
4
  export { CONSOLE as ACCESS_DENIED_CONSOLE, escapeHtml, renderAccessDeniedPage, resolveAccessDeniedPage, } from './access_denied_page.js';
5
5
  // Built-in `dashboardAuth` login screen (optional; opt-in via `config/durable_dashboard.ts`).
@@ -1,5 +1,5 @@
1
1
  /** Keep in sync with this package's `version` in package.json. */
2
- export declare const VERSION = "0.31.1";
2
+ export declare const VERSION = "0.31.2";
3
3
  export { configure } from '../configure.js';
4
4
  export * from './admission.js';
5
5
  export type { AdmissionContext, AdmissionFactory, RedisAdmissionConfig, } from './admissions/factory.js';
package/dist/src/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /** Keep in sync with this package's `version` in package.json. */
2
- export const VERSION = '0.31.1';
2
+ export const VERSION = '0.31.2';
3
3
  // Re-export the configure hook from the package root so `node ace configure` finds it.
4
4
  // AdonisJS imports the package MAIN and reads `configure` off the module namespace —
5
5
  // the `./configure` subpath alone is never consulted.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adonis-agora/durable",
3
- "version": "0.31.1",
3
+ "version": "0.31.2",
4
4
  "description": "Durable cross-app workflows for AdonisJS — deterministic replay engine, AdonisJS binding, ace commands, dashboard, OpenTelemetry, Telescope, testing harness and Redis admission, all in one package. Part of the Agora ecosystem.",
5
5
  "license": "MIT",
6
6
  "repository": {