@jskit-ai/storage-runtime 0.1.16 → 0.1.17

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.
@@ -1,7 +1,8 @@
1
1
  export default Object.freeze({
2
2
  packageVersion: 1,
3
3
  packageId: "@jskit-ai/storage-runtime",
4
- version: "0.1.16",
4
+ version: "0.1.17",
5
+ kind: "runtime",
5
6
  dependsOn: [
6
7
  "@jskit-ai/kernel"
7
8
  ],
@@ -40,7 +41,7 @@ export default Object.freeze({
40
41
  containerTokens: {
41
42
  server: [
42
43
  "runtime.storage",
43
- "KERNEL_TOKENS.Storage"
44
+ "jskit.storage"
44
45
  ],
45
46
  client: []
46
47
  }
@@ -49,7 +50,7 @@ export default Object.freeze({
49
50
  mutations: {
50
51
  dependencies: {
51
52
  runtime: {
52
- "@jskit-ai/kernel": "0.1.17",
53
+ "@jskit-ai/kernel": "0.1.18",
53
54
  "unstorage": "^1.17.3"
54
55
  },
55
56
  dev: {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/storage-runtime",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -10,7 +10,7 @@
10
10
  "./server/providers/StorageRuntimeServiceProvider": "./src/server/providers/StorageRuntimeServiceProvider.js"
11
11
  },
12
12
  "dependencies": {
13
- "@jskit-ai/kernel": "0.1.17",
13
+ "@jskit-ai/kernel": "0.1.18",
14
14
  "unstorage": "^1.17.3"
15
15
  }
16
16
  }
@@ -1,13 +1,11 @@
1
- import { KERNEL_TOKENS } from "@jskit-ai/kernel/shared/support/tokens";
2
1
  import * as storageBinding from "../storageBinding.js";
3
2
 
4
- const STORAGE_RUNTIME_SERVER_TOKEN = "runtime.storage";
5
3
  const STORAGE_RUNTIME_SERVER_API = Object.freeze({
6
4
  ...storageBinding
7
5
  });
8
6
 
9
7
  class StorageRuntimeServiceProvider {
10
- static id = STORAGE_RUNTIME_SERVER_TOKEN;
8
+ static id = "runtime.storage";
11
9
 
12
10
  static dependsOn = ["runtime.server"];
13
11
 
@@ -16,11 +14,11 @@ class StorageRuntimeServiceProvider {
16
14
  throw new Error("StorageRuntimeServiceProvider requires application singleton().");
17
15
  }
18
16
 
19
- app.singleton(STORAGE_RUNTIME_SERVER_TOKEN, () => STORAGE_RUNTIME_SERVER_API);
20
- app.singleton(KERNEL_TOKENS.Storage, (scope) => storageBinding.createStorageBinding(scope));
17
+ app.singleton("runtime.storage", () => STORAGE_RUNTIME_SERVER_API);
18
+ app.singleton("jskit.storage", (scope) => storageBinding.createStorageBinding(scope));
21
19
  }
22
20
 
23
21
  boot() {}
24
22
  }
25
23
 
26
- export { STORAGE_RUNTIME_SERVER_TOKEN, StorageRuntimeServiceProvider };
24
+ export { StorageRuntimeServiceProvider };
@@ -3,7 +3,6 @@ import path from "node:path";
3
3
  import { createStorage } from "unstorage";
4
4
  import fsDriver from "unstorage/drivers/fs";
5
5
  import memoryDriver from "unstorage/drivers/memory";
6
- import { KERNEL_TOKENS } from "@jskit-ai/kernel/shared/support/tokens";
7
6
 
8
7
  const STORAGE_DRIVER_ENV_KEY = "JSKIT_STORAGE_DRIVER";
9
8
  const STORAGE_FS_BASE_PATH_ENV_KEY = "JSKIT_STORAGE_FS_BASE_PATH";
@@ -25,7 +24,7 @@ function resolveFsBasePath(fsBasePath, { rootDir } = {}) {
25
24
  }
26
25
 
27
26
  function createStorageBinding(scope, { rootDir = process.cwd() } = {}) {
28
- const env = scope && typeof scope.has === "function" && scope.has(KERNEL_TOKENS.Env) ? scope.make(KERNEL_TOKENS.Env) : {};
27
+ const env = scope && typeof scope.has === "function" && scope.has("jskit.env") ? scope.make("jskit.env") : {};
29
28
  const driver = normalizeStorageDriver(env?.[STORAGE_DRIVER_ENV_KEY]);
30
29
 
31
30
  if (driver === "memory") {
@@ -1,6 +1,5 @@
1
1
  import test from "node:test";
2
2
  import assert from "node:assert/strict";
3
- import { KERNEL_TOKENS } from "@jskit-ai/kernel/shared/support/tokens";
4
3
  import { StorageRuntimeServiceProvider } from "../src/server/providers/StorageRuntimeServiceProvider.js";
5
4
 
6
5
  function createSingletonApp() {
@@ -24,7 +23,7 @@ function createSingletonApp() {
24
23
 
25
24
  test("StorageRuntimeServiceProvider registers runtime storage api and storage binding", async () => {
26
25
  const app = createSingletonApp();
27
- app.singleton(KERNEL_TOKENS.Env, () => ({
26
+ app.singleton("jskit.env", () => ({
28
27
  JSKIT_STORAGE_DRIVER: "memory"
29
28
  }));
30
29
 
@@ -32,12 +31,12 @@ test("StorageRuntimeServiceProvider registers runtime storage api and storage bi
32
31
  provider.register(app);
33
32
 
34
33
  assert.equal(app.has("runtime.storage"), true);
35
- assert.equal(app.has(KERNEL_TOKENS.Storage), true);
34
+ assert.equal(app.has("jskit.storage"), true);
36
35
 
37
36
  const runtimeStorageApi = app.make("runtime.storage");
38
37
  assert.equal(typeof runtimeStorageApi.createStorageBinding, "function");
39
38
 
40
- const storage = app.make(KERNEL_TOKENS.Storage);
39
+ const storage = app.make("jskit.storage");
41
40
  assert.equal(typeof storage.setItemRaw, "function");
42
41
  assert.equal(typeof storage.getItemRaw, "function");
43
42