@hapergg/harness-comet-adapter-memory 0.1.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/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/package.json +48 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAUjE,wBAAgB,mBAAmB,IAAI,cAAc,CAmDpD;;AAED,wBAAqC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function asObject(input) {
|
|
2
|
+
if (!input || typeof input !== "object" || Array.isArray(input)) {
|
|
3
|
+
throw new Error("Input must be an object");
|
|
4
|
+
}
|
|
5
|
+
return input;
|
|
6
|
+
}
|
|
7
|
+
export function createMemoryAdapter() {
|
|
8
|
+
const store = new Map();
|
|
9
|
+
return {
|
|
10
|
+
name: "memory",
|
|
11
|
+
actions: {
|
|
12
|
+
"memory.set": {
|
|
13
|
+
async execute(input) {
|
|
14
|
+
const object = asObject(input);
|
|
15
|
+
const key = String(object.key);
|
|
16
|
+
store.set(key, object.value ?? null);
|
|
17
|
+
return { values: { [key]: object.value ?? null } };
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"memory.merge": {
|
|
21
|
+
async execute(input) {
|
|
22
|
+
const object = asObject(input);
|
|
23
|
+
const key = String(object.key);
|
|
24
|
+
const current = store.get(key);
|
|
25
|
+
if (!current || typeof current !== "object" || Array.isArray(current)) {
|
|
26
|
+
store.set(key, object.value ?? {});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
store.set(key, {
|
|
30
|
+
...current,
|
|
31
|
+
...asObject(object.value ?? {})
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return { values: { [key]: store.get(key) ?? null } };
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"memory.delete": {
|
|
38
|
+
async execute(input) {
|
|
39
|
+
const object = asObject(input);
|
|
40
|
+
store.delete(String(object.key));
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
inspectors: {
|
|
46
|
+
"memory.get": {
|
|
47
|
+
async inspect(input) {
|
|
48
|
+
const object = asObject(input);
|
|
49
|
+
return store.get(String(object.key)) ?? null;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"memory.all": {
|
|
53
|
+
async inspect() {
|
|
54
|
+
return Object.fromEntries(store.entries());
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export default createMemoryAdapter();
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,SAAS,QAAQ,CAAC,KAAgB;IAChC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC3C,OAAO;QACL,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE;YACP,YAAY,EAAE;gBACZ,KAAK,CAAC,OAAO,CAAC,KAAK;oBACjB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAC/B,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBAC/B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YACV,YAAY,EAAE;gBACZ,KAAK,CAAC,OAAO,CAAC,KAAK;oBACjB,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;oBAC/B,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;gBAC/C,CAAC;aACF;YACD,YAAY,EAAE;gBACZ,KAAK,CAAC,OAAO;oBACX,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,CAA8B,CAAC;gBAC1E,CAAC;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,eAAe,mBAAmB,EAAE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hapergg/harness-comet-adapter-memory",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "In-memory Harness Comet adapter for lightweight runtime scenarios.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/HarperGG/harness-comet.git",
|
|
13
|
+
"directory": "packages/adapter-memory"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/HarperGG/harness-comet#readme",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/HarperGG/harness-comet/issues"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.org/"
|
|
25
|
+
},
|
|
26
|
+
"main": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@hapergg/harness-comet-schema": "0.1.0",
|
|
37
|
+
"@hapergg/harness-comet-sdk": "0.1.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.9.3",
|
|
41
|
+
"vitest": "^4.0.14"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
45
|
+
"build": "tsc -b",
|
|
46
|
+
"test": "vitest run"
|
|
47
|
+
}
|
|
48
|
+
}
|