@jsm-mit/sultana-assets-rust-package 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -56,9 +56,9 @@ types are exported too, and `./declarations/*` gives the generated files.
56
56
  `src/` is browser-safe — the same package serves the biz panel, the playground and the
57
57
  transcoding worker.
58
58
 
59
- Scripts: `build`, `typecheck`, `sync-declarations`, `test-suite`, `redeploy`, `sandbox`
59
+ Scripts: `build`, `typecheck`, `sync-declarations`, `test-suite`, `test-smoke`, `test-upgrade`, `redeploy`, `sandbox`
60
60
  (an interactive console: `npm run sandbox -- <canister-id>`, caller from `IDENTITY_PEM` in
61
- `.env` or anonymous), `stamp-canister`, `publish-public`. See `CLAUDE.md` for who runs what.
61
+ `.env.sandbox` or anonymous), `stamp-canister`, `publish-public`. See `CLAUDE.md` for who runs what.
62
62
 
63
63
  ## Integration tests
64
64
 
@@ -67,6 +67,11 @@ table's `short-living` slot (lease 3 minutes) and runs `tests/test-suite.ts` the
67
67
  `.env`, no PEMs: every identity is generated per run. A fresh canister has no core canister,
68
68
  so the suite claims that claim-once seat for a generated identity and plays core itself.
69
69
 
70
+ `npm run test-smoke` does the same with `tests/test-smoke.ts`: setup, then one write and one
71
+ read per domain (worker list, a few-byte single-shot upload read back over HTTP, a worker
72
+ result, a salon upload refused by the stand-in core), one replication wait, ≈ 30 s.
73
+ `publish-public` runs it too.
74
+
70
75
  What the suite covers: the core seat and the worker list; chunked and single-shot uploads
71
76
  with every owner and size check; reads, HTTP 200/206/404, certification header and
72
77
  streaming; the worker's system upload with a poster; `delete_asset` taking the thumb along;
@@ -79,8 +84,9 @@ the suite never touches it.
79
84
 
80
85
  Bump the version by hand, commit, push, then `npm run publish-public`. It refuses unless this
81
86
  repo and `../sultana-assets-rust` are on a clean, pushed `master` and the version is new on
82
- npm; it reinstalls the canister's master into `short-living` (lease 1), checks that its
87
+ npm; it reinstalls the canister's master into `short-living` (lease 2), checks that its
83
88
  `candid:service` equals `declarations/sultana-assets-rust/sultana-assets-rust.did` as dfx
84
- rewrites it (the hand-written .did is normalized by a local `dfx build --check` first), stamps
89
+ rewrites it (the hand-written .did is normalized by a local `dfx build --check` first), runs
90
+ the smoke test (`tests/test-smoke.ts`) on that same deploy, stamps
85
91
  `sultanaAssets.{repo, repoUrl, commit}` into package.json, publishes and commits `Version bump
86
92
  to <version>`.
@@ -80,6 +80,7 @@ service : () -> {
80
80
  finish_system_upload : (FinishSystemUploadArgs) -> (text);
81
81
  finish_upload : (text) -> (text);
82
82
  get_asset_info : (text) -> (opt AssetInfo) query;
83
+ get_coordinator : () -> (opt principal) query;
83
84
  get_core_canister : () -> (opt principal) query;
84
85
  get_workers : () -> (vec WorkerEntry) query;
85
86
  http_request : (HttpRequest) -> (HttpResponse) query;
@@ -88,6 +89,7 @@ service : () -> {
88
89
  reserve_render : (ReserveRenderArgs) -> (ReserveTranscodingUpload);
89
90
  reserve_transcoding_upload : (ReserveTranscodingUploadArgs) -> (ReserveTranscodingUpload);
90
91
  run_reservation_sweep : (nat64) -> (nat32);
92
+ set_coordinator : (opt principal) -> (bool);
91
93
  set_core_canister : (principal) -> (bool);
92
94
  set_workers : (vec WorkerEntry) -> (bool);
93
95
  start_upload : (StartUploadArgs) -> (text);
@@ -100,6 +100,7 @@ export interface _SERVICE {
100
100
  'finish_system_upload' : ActorMethod<[FinishSystemUploadArgs], string>,
101
101
  'finish_upload' : ActorMethod<[string], string>,
102
102
  'get_asset_info' : ActorMethod<[string], [] | [AssetInfo]>,
103
+ 'get_coordinator' : ActorMethod<[], [] | [Principal]>,
103
104
  'get_core_canister' : ActorMethod<[], [] | [Principal]>,
104
105
  'get_workers' : ActorMethod<[], Array<WorkerEntry>>,
105
106
  'http_request' : ActorMethod<[HttpRequest], HttpResponse>,
@@ -114,6 +115,7 @@ export interface _SERVICE {
114
115
  ReserveTranscodingUpload
115
116
  >,
116
117
  'run_reservation_sweep' : ActorMethod<[bigint], number>,
118
+ 'set_coordinator' : ActorMethod<[[] | [Principal]], boolean>,
117
119
  'set_core_canister' : ActorMethod<[Principal], boolean>,
118
120
  'set_workers' : ActorMethod<[Array<WorkerEntry>], boolean>,
119
121
  'start_upload' : ActorMethod<[StartUploadArgs], string>,
@@ -111,6 +111,7 @@ export const idlFactory = ({ IDL }) => {
111
111
  'finish_system_upload' : IDL.Func([FinishSystemUploadArgs], [IDL.Text], []),
112
112
  'finish_upload' : IDL.Func([IDL.Text], [IDL.Text], []),
113
113
  'get_asset_info' : IDL.Func([IDL.Text], [IDL.Opt(AssetInfo)], ['query']),
114
+ 'get_coordinator' : IDL.Func([], [IDL.Opt(IDL.Principal)], ['query']),
114
115
  'get_core_canister' : IDL.Func([], [IDL.Opt(IDL.Principal)], ['query']),
115
116
  'get_workers' : IDL.Func([], [IDL.Vec(WorkerEntry)], ['query']),
116
117
  'http_request' : IDL.Func([HttpRequest], [HttpResponse], ['query']),
@@ -131,6 +132,7 @@ export const idlFactory = ({ IDL }) => {
131
132
  [],
132
133
  ),
133
134
  'run_reservation_sweep' : IDL.Func([IDL.Nat64], [IDL.Nat32], []),
135
+ 'set_coordinator' : IDL.Func([IDL.Opt(IDL.Principal)], [IDL.Bool], []),
134
136
  'set_core_canister' : IDL.Func([IDL.Principal], [IDL.Bool], []),
135
137
  'set_workers' : IDL.Func([IDL.Vec(WorkerEntry)], [IDL.Bool], []),
136
138
  'start_upload' : IDL.Func([StartUploadArgs], [IDL.Text], []),
@@ -27,6 +27,27 @@ export declare class AssetsRustAdminActor extends ActorBase {
27
27
  * @throws CriticalCanisterError - Transport failure or an unreachable canister.
28
28
  */
29
29
  getCoreCanisterAsyncUnsafe(): Promise<string | null>;
30
+ /**
31
+ * Core-canister only: the coordinator of the sharded group (sultana-sharded) whose workers
32
+ * hold the salons — the trusted calls of a salon then go to its worker. The real path is
33
+ * the group core's `linkAssetsToGroup` (sultana-sharded-package
34
+ * `AdminActor.linkAssetsToGroupAsyncUnsafe`); `null` goes back to the one core.
35
+ * @param coordinatorPrincipal - The group's coordinator, or `null`.
36
+ * @returns A Promise that resolves to `true` when set, `false` when the caller is not the
37
+ * core canister.
38
+ * @throws CanisterError - The canister trapped.
39
+ * @throws CallRefusedAtInspectionStage - The call was refused at the inspect stage.
40
+ * @throws CriticalCanisterError - Transport failure or an unreachable canister.
41
+ */
42
+ setCoordinatorAsyncUnsafe(coordinatorPrincipal: string | null): Promise<boolean>;
43
+ /**
44
+ * @returns A Promise that resolves to the coordinator of the sharded group, or `null` when
45
+ * the canister serves one core.
46
+ * @throws CanisterError - The canister trapped.
47
+ * @throws CallRefusedAtInspectionStage - The call was refused at the inspect stage.
48
+ * @throws CriticalCanisterError - Transport failure or an unreachable canister.
49
+ */
50
+ getCoordinatorAsyncUnsafe(): Promise<string | null>;
30
51
  /**
31
52
  * Core-canister only: replaces the transcoding-worker list. The real path is core's
32
53
  * superadmin proxy (sultana-core-motoko-package `AdminActor.setAssetWorkersAsyncUnsafe`).
@@ -1 +1 @@
1
- {"version":3,"file":"admin-actor.d.ts","sourceRoot":"","sources":["../../src/actors/admin-actor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IAC/C;;;;;;;;;OASG;IACU,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhF;;;;;;OAMG;IACU,0BAA0B,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKjE;;;;;;;;;OASG;IACU,qBAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3E;;;;;;OAMG;IACU,qBAAqB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAK3D;;;;;;;;;;OAUG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItE;;;;;;;;OAQG;IACU,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG9E"}
1
+ {"version":3,"file":"admin-actor.d.ts","sourceRoot":"","sources":["../../src/actors/admin-actor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD;;;;;;GAMG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;IAC/C;;;;;;;;;OASG;IACU,0BAA0B,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIhF;;;;;;OAMG;IACU,0BAA0B,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKjE;;;;;;;;;;;OAWG;IACU,yBAAyB,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC;IAI7F;;;;;;OAMG;IACU,yBAAyB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAKhE;;;;;;;;;OASG;IACU,qBAAqB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC;IAI3E;;;;;;OAMG;IACU,qBAAqB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAK3D;;;;;;;;;;OAUG;IACU,sBAAsB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAItE;;;;;;;;OAQG;IACU,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG9E"}
@@ -33,6 +33,32 @@ export class AssetsRustAdminActor extends ActorBase {
33
33
  const result = await this.executeFunctionAsyncUnsafe(() => this.actor.get_core_canister());
34
34
  return result.length === 0 ? null : result[0].toText();
35
35
  }
36
+ /**
37
+ * Core-canister only: the coordinator of the sharded group (sultana-sharded) whose workers
38
+ * hold the salons — the trusted calls of a salon then go to its worker. The real path is
39
+ * the group core's `linkAssetsToGroup` (sultana-sharded-package
40
+ * `AdminActor.linkAssetsToGroupAsyncUnsafe`); `null` goes back to the one core.
41
+ * @param coordinatorPrincipal - The group's coordinator, or `null`.
42
+ * @returns A Promise that resolves to `true` when set, `false` when the caller is not the
43
+ * core canister.
44
+ * @throws CanisterError - The canister trapped.
45
+ * @throws CallRefusedAtInspectionStage - The call was refused at the inspect stage.
46
+ * @throws CriticalCanisterError - Transport failure or an unreachable canister.
47
+ */
48
+ async setCoordinatorAsyncUnsafe(coordinatorPrincipal) {
49
+ return this.executeFunctionAsyncUnsafe(() => this.actor.set_coordinator(coordinatorPrincipal === null ? [] : [Principal.fromText(coordinatorPrincipal)]));
50
+ }
51
+ /**
52
+ * @returns A Promise that resolves to the coordinator of the sharded group, or `null` when
53
+ * the canister serves one core.
54
+ * @throws CanisterError - The canister trapped.
55
+ * @throws CallRefusedAtInspectionStage - The call was refused at the inspect stage.
56
+ * @throws CriticalCanisterError - Transport failure or an unreachable canister.
57
+ */
58
+ async getCoordinatorAsyncUnsafe() {
59
+ const result = await this.executeFunctionAsyncUnsafe(() => this.actor.get_coordinator());
60
+ return result.length === 0 ? null : result[0].toText();
61
+ }
36
62
  /**
37
63
  * Core-canister only: replaces the transcoding-worker list. The real path is core's
38
64
  * superadmin proxy (sultana-core-motoko-package `AdminActor.setAssetWorkersAsyncUnsafe`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsm-mit/sultana-assets-rust-package",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Wrapper TypeScript package for the sultana-assets-rust canister: chunked and single-shot uploads, salon images and transcoding reservations, the worker upload path, reads and asset URLs.",
5
5
  "license": "ISC",
6
6
  "author": "",
@@ -26,6 +26,8 @@
26
26
  "typecheck": "tsc --noEmit -p tsconfig.tests.json",
27
27
  "sync-declarations": "bash scripts/sync-declarations.sh",
28
28
  "test-suite": "bash scripts/run-tests.sh tests/test-suite.ts --lease 3",
29
+ "test-smoke": "bash scripts/run-tests.sh tests/test-smoke.ts --lease 3",
30
+ "test-upgrade": "bash scripts/run-tests.sh tests/test-upgrade.ts --lease 6",
29
31
  "redeploy": "bash scripts/redeploy.sh",
30
32
  "sandbox": "npx tsx sandbox/main.ts",
31
33
  "stamp-canister": "bash scripts/stamp-canister-commit.sh"
@@ -53,6 +55,6 @@
53
55
  "sultanaAssets": {
54
56
  "repo": "sultana-assets-rust",
55
57
  "repoUrl": "https://github.com/JSM-Sultana/sultana-assets-rust",
56
- "commit": "a2fcfea02282aa858d683bddb26297f2091c431c"
58
+ "commit": "2360e780f543b7bb4eb2d67cc9e6f63d784bd404"
57
59
  }
58
60
  }