@optimizely/ocp-local-env 1.0.0-beta.4
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 +165 -0
- package/dist/package.json +104 -0
- package/dist/public/bundle.da978bb5437cd82e6d37.js +3 -0
- package/dist/public/bundle.da978bb5437cd82e6d37.js.LICENSE.txt +49 -0
- package/dist/public/bundle.da978bb5437cd82e6d37.js.map +1 -0
- package/dist/public/index.html +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +88 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/executor/FunctionExecutor.d.ts +56 -0
- package/dist/src/executor/FunctionExecutor.js +175 -0
- package/dist/src/executor/FunctionExecutor.js.map +1 -0
- package/dist/src/executor/JobExecutor.d.ts +60 -0
- package/dist/src/executor/JobExecutor.js +203 -0
- package/dist/src/executor/JobExecutor.js.map +1 -0
- package/dist/src/executor/LifecycleExecutor.d.ts +45 -0
- package/dist/src/executor/LifecycleExecutor.js +153 -0
- package/dist/src/executor/LifecycleExecutor.js.map +1 -0
- package/dist/src/executor/watcher.d.ts +63 -0
- package/dist/src/executor/watcher.js +213 -0
- package/dist/src/executor/watcher.js.map +1 -0
- package/dist/src/functions/hello.d.ts +4 -0
- package/dist/src/functions/hello.js +8 -0
- package/dist/src/functions/hello.js.map +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/jobs/dailyJob.d.ts +4 -0
- package/dist/src/jobs/dailyJob.js +8 -0
- package/dist/src/jobs/dailyJob.js.map +1 -0
- package/dist/src/local_engine/LocalNotifier.d.ts +10 -0
- package/dist/src/local_engine/LocalNotifier.js +26 -0
- package/dist/src/local_engine/LocalNotifier.js.map +1 -0
- package/dist/src/local_engine/local-engine-child-base.d.ts +79 -0
- package/dist/src/local_engine/local-engine-child-base.js +304 -0
- package/dist/src/local_engine/local-engine-child-base.js.map +1 -0
- package/dist/src/local_engine/local-engine-client.d.ts +80 -0
- package/dist/src/local_engine/local-engine-client.js +333 -0
- package/dist/src/local_engine/local-engine-client.js.map +1 -0
- package/dist/src/local_engine/local-engine-types.d.ts +132 -0
- package/dist/src/local_engine/local-engine-types.js +6 -0
- package/dist/src/local_engine/local-engine-types.js.map +1 -0
- package/dist/src/local_engine/local-engine-unified.d.ts +40 -0
- package/dist/src/local_engine/local-engine-unified.js +406 -0
- package/dist/src/local_engine/local-engine-unified.js.map +1 -0
- package/dist/src/local_engine/local-engine-utils.d.ts +70 -0
- package/dist/src/local_engine/local-engine-utils.js +192 -0
- package/dist/src/local_engine/local-engine-utils.js.map +1 -0
- package/dist/src/local_engine/localSDKConfig.d.ts +30 -0
- package/dist/src/local_engine/localSDKConfig.js +392 -0
- package/dist/src/local_engine/localSDKConfig.js.map +1 -0
- package/dist/src/local_engine/storage/LocalConfigStore.d.ts +56 -0
- package/dist/src/local_engine/storage/LocalConfigStore.js +129 -0
- package/dist/src/local_engine/storage/LocalConfigStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalJobStore.d.ts +110 -0
- package/dist/src/local_engine/storage/LocalJobStore.js +239 -0
- package/dist/src/local_engine/storage/LocalJobStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalKVStore.d.ts +105 -0
- package/dist/src/local_engine/storage/LocalKVStore.js +1002 -0
- package/dist/src/local_engine/storage/LocalKVStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.d.ts +27 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.js +125 -0
- package/dist/src/local_engine/storage/LocalNotificationStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.d.ts +114 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.js +319 -0
- package/dist/src/local_engine/storage/LocalSecretsStore.js.map +1 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.d.ts +161 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.js +417 -0
- package/dist/src/local_engine/storage/LocalSettingsStore.js.map +1 -0
- package/dist/src/local_engine/storage/NumberSet.d.ts +21 -0
- package/dist/src/local_engine/storage/NumberSet.js +32 -0
- package/dist/src/local_engine/storage/NumberSet.js.map +1 -0
- package/dist/src/local_engine/storage/StringSet.d.ts +21 -0
- package/dist/src/local_engine/storage/StringSet.js +32 -0
- package/dist/src/local_engine/storage/StringSet.js.map +1 -0
- package/dist/src/local_engine/types.d.ts +52 -0
- package/dist/src/local_engine/types.js +6 -0
- package/dist/src/local_engine/types.js.map +1 -0
- package/dist/src/local_engine/utils.d.ts +31 -0
- package/dist/src/local_engine/utils.js +126 -0
- package/dist/src/local_engine/utils.js.map +1 -0
- package/dist/src/logging/LogManager.d.ts +89 -0
- package/dist/src/logging/LogManager.js +237 -0
- package/dist/src/logging/LogManager.js.map +1 -0
- package/dist/src/server/api/functions.d.ts +7 -0
- package/dist/src/server/api/functions.js +80 -0
- package/dist/src/server/api/functions.js.map +1 -0
- package/dist/src/server/api/jobs.d.ts +8 -0
- package/dist/src/server/api/jobs.js +242 -0
- package/dist/src/server/api/jobs.js.map +1 -0
- package/dist/src/server/api/lifecycle.d.ts +6 -0
- package/dist/src/server/api/lifecycle.js +73 -0
- package/dist/src/server/api/lifecycle.js.map +1 -0
- package/dist/src/server/api/settings.d.ts +6 -0
- package/dist/src/server/api/settings.js +117 -0
- package/dist/src/server/api/settings.js.map +1 -0
- package/dist/src/server/api/stores.d.ts +2 -0
- package/dist/src/server/api/stores.js +341 -0
- package/dist/src/server/api/stores.js.map +1 -0
- package/dist/src/server/api/v1.d.ts +10 -0
- package/dist/src/server/api/v1.js +711 -0
- package/dist/src/server/api/v1.js.map +1 -0
- package/dist/src/server/api.d.ts +8 -0
- package/dist/src/server/api.js +154 -0
- package/dist/src/server/api.js.map +1 -0
- package/dist/src/server/app-discovery.d.ts +5 -0
- package/dist/src/server/app-discovery.js +81 -0
- package/dist/src/server/app-discovery.js.map +1 -0
- package/dist/src/server/config.d.ts +21 -0
- package/dist/src/server/config.js +100 -0
- package/dist/src/server/config.js.map +1 -0
- package/dist/src/server/websocket.d.ts +0 -0
- package/dist/src/server/websocket.js +2 -0
- package/dist/src/server/websocket.js.map +1 -0
- package/dist/src/server.d.ts +2 -0
- package/dist/src/server.js +546 -0
- package/dist/src/server.js.map +1 -0
- package/dist/src/types/app.d.ts +155 -0
- package/dist/src/types/app.js +24 -0
- package/dist/src/types/app.js.map +1 -0
- package/dist/src/types/kvstore.d.ts +320 -0
- package/dist/src/types/kvstore.js +5 -0
- package/dist/src/types/kvstore.js.map +1 -0
- package/dist/src/ui/components/App.d.ts +6 -0
- package/dist/src/ui/components/App.js +255 -0
- package/dist/src/ui/components/App.js.map +1 -0
- package/dist/src/ui/components/FunctionsView.d.ts +6 -0
- package/dist/src/ui/components/FunctionsView.js +217 -0
- package/dist/src/ui/components/FunctionsView.js.map +1 -0
- package/dist/src/ui/components/JobsView.d.ts +6 -0
- package/dist/src/ui/components/JobsView.js +257 -0
- package/dist/src/ui/components/JobsView.js.map +1 -0
- package/dist/src/ui/components/KVStoreViewer.d.ts +11 -0
- package/dist/src/ui/components/KVStoreViewer.js +168 -0
- package/dist/src/ui/components/KVStoreViewer.js.map +1 -0
- package/dist/src/ui/components/NotificationViewer.d.ts +16 -0
- package/dist/src/ui/components/NotificationViewer.js +69 -0
- package/dist/src/ui/components/NotificationViewer.js.map +1 -0
- package/dist/src/ui/components/SecretsStoreViewer.d.ts +11 -0
- package/dist/src/ui/components/SecretsStoreViewer.js +179 -0
- package/dist/src/ui/components/SecretsStoreViewer.js.map +1 -0
- package/dist/src/ui/components/SettingsStoreViewer.d.ts +24 -0
- package/dist/src/ui/components/SettingsStoreViewer.js +132 -0
- package/dist/src/ui/components/SettingsStoreViewer.js.map +1 -0
- package/dist/src/ui/components/StoreViewer.d.ts +16 -0
- package/dist/src/ui/components/StoreViewer.js +86 -0
- package/dist/src/ui/components/StoreViewer.js.map +1 -0
- package/dist/src/ui/components/TabbedConsole.d.ts +15 -0
- package/dist/src/ui/components/TabbedConsole.js +93 -0
- package/dist/src/ui/components/TabbedConsole.js.map +1 -0
- package/dist/src/ui/components/common/DataTree.d.ts +15 -0
- package/dist/src/ui/components/common/DataTree.js +95 -0
- package/dist/src/ui/components/common/DataTree.js.map +1 -0
- package/dist/src/ui/components/common/EyeIcon.d.ts +11 -0
- package/dist/src/ui/components/common/EyeIcon.js +11 -0
- package/dist/src/ui/components/common/EyeIcon.js.map +1 -0
- package/dist/src/ui/index.d.ts +1 -0
- package/dist/src/ui/index.js +20 -0
- package/dist/src/ui/index.js.map +1 -0
- package/package.json +104 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { AppManifest } from '@zaiusinc/app-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a discovered OCP app
|
|
4
|
+
*/
|
|
5
|
+
export interface App {
|
|
6
|
+
manifest: AppManifest;
|
|
7
|
+
path: string;
|
|
8
|
+
isBuilt: boolean;
|
|
9
|
+
isValid: boolean;
|
|
10
|
+
errors?: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Context provided to functions and jobs during execution
|
|
14
|
+
*/
|
|
15
|
+
export interface ExecutionContext {
|
|
16
|
+
settings: Record<string, any>;
|
|
17
|
+
logger: {
|
|
18
|
+
info: (message: string) => void;
|
|
19
|
+
error: (message: string) => void;
|
|
20
|
+
debug: (message: string) => void;
|
|
21
|
+
warn: (message: string) => void;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Function execution request
|
|
26
|
+
*/
|
|
27
|
+
export interface FunctionExecutionRequest {
|
|
28
|
+
functionId: string;
|
|
29
|
+
payload: any;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Function execution response
|
|
33
|
+
*/
|
|
34
|
+
export interface FunctionExecutionResponse {
|
|
35
|
+
result: any;
|
|
36
|
+
logs: string[];
|
|
37
|
+
error?: {
|
|
38
|
+
message: string;
|
|
39
|
+
stack?: string;
|
|
40
|
+
};
|
|
41
|
+
executionTime: number;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Job execution request
|
|
45
|
+
*/
|
|
46
|
+
export interface JobExecutionRequest {
|
|
47
|
+
jobId: string;
|
|
48
|
+
payload?: any;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Lifecycle hook types
|
|
52
|
+
*/
|
|
53
|
+
export declare enum LifecycleHookType {
|
|
54
|
+
INSTALL = "install",
|
|
55
|
+
UNINSTALL = "uninstall",
|
|
56
|
+
UPGRADE = "upgrade"
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Lifecycle hook execution request
|
|
60
|
+
*/
|
|
61
|
+
export interface LifecycleHookExecutionRequest {
|
|
62
|
+
type: LifecycleHookType;
|
|
63
|
+
context?: {
|
|
64
|
+
previousVersion?: string;
|
|
65
|
+
settings?: Record<string, any>;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Lifecycle hook execution response
|
|
70
|
+
*/
|
|
71
|
+
export interface LifecycleHookExecutionResponse {
|
|
72
|
+
success: boolean;
|
|
73
|
+
logs: string[];
|
|
74
|
+
error?: {
|
|
75
|
+
message: string;
|
|
76
|
+
stack?: string;
|
|
77
|
+
};
|
|
78
|
+
executionTime: number;
|
|
79
|
+
result?: any;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Job execution status enum
|
|
83
|
+
*/
|
|
84
|
+
export declare enum JobExecutionStatus {
|
|
85
|
+
PENDING = "pending",
|
|
86
|
+
RUNNING = "running",
|
|
87
|
+
COMPLETED = "completed",
|
|
88
|
+
FAILED = "failed",
|
|
89
|
+
INTERRUPTED = "interrupted"
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Job execution request
|
|
93
|
+
*/
|
|
94
|
+
export interface JobExecutionRequest {
|
|
95
|
+
jobId: string;
|
|
96
|
+
parameters?: Record<string, any>;
|
|
97
|
+
dataSyncId?: string;
|
|
98
|
+
sourceKey?: string;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Job execution response
|
|
102
|
+
*/
|
|
103
|
+
export interface JobExecutionResponse {
|
|
104
|
+
success: boolean;
|
|
105
|
+
executionId: string;
|
|
106
|
+
status: JobExecutionStatus;
|
|
107
|
+
startedAt: Date;
|
|
108
|
+
completedAt?: Date;
|
|
109
|
+
logs: string[];
|
|
110
|
+
error?: {
|
|
111
|
+
message: string;
|
|
112
|
+
stack?: string;
|
|
113
|
+
};
|
|
114
|
+
executionTime?: number;
|
|
115
|
+
stateCount: number;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Job execution record
|
|
119
|
+
*/
|
|
120
|
+
export interface JobExecution {
|
|
121
|
+
id: string;
|
|
122
|
+
jobId: string;
|
|
123
|
+
status: JobExecutionStatus;
|
|
124
|
+
startedAt: Date;
|
|
125
|
+
completedAt?: Date;
|
|
126
|
+
parameters: Record<string, any>;
|
|
127
|
+
error?: {
|
|
128
|
+
message: string;
|
|
129
|
+
stack?: string;
|
|
130
|
+
};
|
|
131
|
+
executionTime?: number;
|
|
132
|
+
stateCount: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Job state snapshot
|
|
136
|
+
*/
|
|
137
|
+
export interface JobState {
|
|
138
|
+
id: string;
|
|
139
|
+
executionId: string;
|
|
140
|
+
timestamp: Date;
|
|
141
|
+
state: Record<string, any>;
|
|
142
|
+
complete: boolean;
|
|
143
|
+
stateHash: string;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Job definition from app manifest
|
|
147
|
+
*/
|
|
148
|
+
export interface JobDefinition {
|
|
149
|
+
id: string;
|
|
150
|
+
entry_point: string;
|
|
151
|
+
description: string;
|
|
152
|
+
cron?: string;
|
|
153
|
+
parameters?: Record<string, any>;
|
|
154
|
+
isSourceJob?: boolean;
|
|
155
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JobExecutionStatus = exports.LifecycleHookType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Lifecycle hook types
|
|
6
|
+
*/
|
|
7
|
+
var LifecycleHookType;
|
|
8
|
+
(function (LifecycleHookType) {
|
|
9
|
+
LifecycleHookType["INSTALL"] = "install";
|
|
10
|
+
LifecycleHookType["UNINSTALL"] = "uninstall";
|
|
11
|
+
LifecycleHookType["UPGRADE"] = "upgrade";
|
|
12
|
+
})(LifecycleHookType = exports.LifecycleHookType || (exports.LifecycleHookType = {}));
|
|
13
|
+
/**
|
|
14
|
+
* Job execution status enum
|
|
15
|
+
*/
|
|
16
|
+
var JobExecutionStatus;
|
|
17
|
+
(function (JobExecutionStatus) {
|
|
18
|
+
JobExecutionStatus["PENDING"] = "pending";
|
|
19
|
+
JobExecutionStatus["RUNNING"] = "running";
|
|
20
|
+
JobExecutionStatus["COMPLETED"] = "completed";
|
|
21
|
+
JobExecutionStatus["FAILED"] = "failed";
|
|
22
|
+
JobExecutionStatus["INTERRUPTED"] = "interrupted";
|
|
23
|
+
})(JobExecutionStatus = exports.JobExecutionStatus || (exports.JobExecutionStatus = {}));
|
|
24
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/types/app.ts"],"names":[],"mappings":";;;AAwDA;;GAEG;AACH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,wCAAmB,CAAA;IACnB,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;AACrB,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AA2BD;;GAEG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,yCAAmB,CAAA;IACnB,6CAAuB,CAAA;IACvB,uCAAiB,CAAA;IACjB,iDAA2B,CAAA;AAC7B,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B"}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { NumberSet } from "../local_engine/storage/NumberSet";
|
|
2
|
+
import { StringSet } from "../local_engine/storage/StringSet";
|
|
3
|
+
/**
|
|
4
|
+
* A value type that is safe to write to the key-value storage
|
|
5
|
+
*/
|
|
6
|
+
export type Value = string | number | boolean | null | ValueHash;
|
|
7
|
+
/**
|
|
8
|
+
* An object with some restrictions. An interface that follows the ValueHash interface
|
|
9
|
+
* can be safely written to the key-value storage.
|
|
10
|
+
*/
|
|
11
|
+
export interface ValueHash {
|
|
12
|
+
[field: string]: Value | Value[] | NumberSet | StringSet | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Used when patching data.
|
|
16
|
+
* The previous value is provided as the first parameter.
|
|
17
|
+
* The return value will be used to update the record.
|
|
18
|
+
* WARNING: A patch updater may be called multiple times until the update is successful.
|
|
19
|
+
*/
|
|
20
|
+
export type PatchUpdater<T = ValueHash> = (previous: T) => T;
|
|
21
|
+
/**
|
|
22
|
+
* A value type that is safe to write to the key-value storage
|
|
23
|
+
*/
|
|
24
|
+
export type KVValue = Value;
|
|
25
|
+
/**
|
|
26
|
+
* An object with some restrictions. An interface that follows the KVHash interface
|
|
27
|
+
* can be safely written to the key-value storage.
|
|
28
|
+
*/
|
|
29
|
+
export interface KVHash {
|
|
30
|
+
[field: string]: KVValue | KVValue[] | NumberSet | StringSet | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A hash of fields to values of a specific type. Used in the key-value store's "multi" accessors.
|
|
34
|
+
*/
|
|
35
|
+
export interface MultiValue<T> {
|
|
36
|
+
[field: string]: T;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Used when patching data.
|
|
40
|
+
* The previous value is provided as the first parameter. The current TTL is provided in the second parameter.
|
|
41
|
+
* The return value will be used to update the record. Update the options object directly to make a change to the TTL.
|
|
42
|
+
* WARNING: A patch updater may be called multiple times until the update is successful.
|
|
43
|
+
*/
|
|
44
|
+
type KVPatchUpdaterWithOptions<T extends KVHash> = (previous: T, options: KVRowOptions) => T;
|
|
45
|
+
export type KVPatchUpdater<T extends KVHash> = PatchUpdater<T> | KVPatchUpdaterWithOptions<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Options for writing a row to key-value storage.
|
|
48
|
+
*/
|
|
49
|
+
export interface KVRowOptions {
|
|
50
|
+
/**
|
|
51
|
+
* The number of seconds until the row should expire.
|
|
52
|
+
* Set to undefined for no TTL.
|
|
53
|
+
*/
|
|
54
|
+
ttl?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface KVStore {
|
|
57
|
+
/**
|
|
58
|
+
* Retrieve an object from the store given a key.
|
|
59
|
+
* @async
|
|
60
|
+
* @param key of the stored object
|
|
61
|
+
* @param fields to retrieve from the stored object, or undefined to retrieve the full object
|
|
62
|
+
* @returns hash of the complete object or only the specified fields, if supplied.
|
|
63
|
+
* An empty object is returned if the object, or all specified fields, does not exist.
|
|
64
|
+
*/
|
|
65
|
+
get<T extends KVHash>(key: string, fields?: string[]): Promise<T>;
|
|
66
|
+
/**
|
|
67
|
+
* Write an object to the store at a given key. Overwrites the entire object.
|
|
68
|
+
* @async
|
|
69
|
+
* @param key of the stored object
|
|
70
|
+
* @param value complete hash to write
|
|
71
|
+
* @param options optionally set a TTL for this row
|
|
72
|
+
* @returns the previous value found at the key if successful. Otherwise throws an error.
|
|
73
|
+
*/
|
|
74
|
+
put<T extends KVHash>(key: string, value: T, options?: KVRowOptions): Promise<T>;
|
|
75
|
+
/**
|
|
76
|
+
* Write a set of fields to an object in the store at a given key. Does not overwrite the entire object.
|
|
77
|
+
* @async
|
|
78
|
+
* @param key of the stored object
|
|
79
|
+
* @param value hash of fields and values to update the object with. Leaves all other fields untouched.
|
|
80
|
+
* @param options optionally set a TTL for this row
|
|
81
|
+
* @returns the complete object from before the update
|
|
82
|
+
* An empty object is returned if the object previously did not exist.
|
|
83
|
+
*/
|
|
84
|
+
patch<T extends KVHash>(key: string, value: T, options?: KVRowOptions): Promise<T>;
|
|
85
|
+
/**
|
|
86
|
+
* Update a stored object using a callback to make changes.
|
|
87
|
+
* @async
|
|
88
|
+
* @param key of the stored object
|
|
89
|
+
* @param updater function to manipulate the existing object (may be called multiple times to ensure an atomic change)
|
|
90
|
+
* @param options optionally set a TTL for this row
|
|
91
|
+
* @returns the complete object from before the update
|
|
92
|
+
* An empty object is returned if the object previously did not exist.
|
|
93
|
+
*/
|
|
94
|
+
patch<T extends KVHash>(key: string, updater: KVPatchUpdater<T>, options?: KVRowOptions): Promise<T>;
|
|
95
|
+
/**
|
|
96
|
+
* Delete an object or a single field from the store at a given key.
|
|
97
|
+
* If fields is undefined, the entire object will be deleted.
|
|
98
|
+
* @async
|
|
99
|
+
* @param key of the stored object
|
|
100
|
+
* @param fields to delete or undefined to delete all fields
|
|
101
|
+
* @returns the deleted value if successful, or an empty object if it did not exist.
|
|
102
|
+
*/
|
|
103
|
+
delete<T extends KVHash>(key: string, fields?: string[]): Promise<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Check if an object exists at a given key.
|
|
106
|
+
* @async
|
|
107
|
+
* @param key of the stored object
|
|
108
|
+
* @returns true if the object exists
|
|
109
|
+
*/
|
|
110
|
+
exists(key: string): Promise<boolean>;
|
|
111
|
+
/**
|
|
112
|
+
* Atomically increment the value of a numeric field. If the object or field did not previously exist, the resulting
|
|
113
|
+
* field will be set to the given amount. If the field does already exist but is not a number, this will result in
|
|
114
|
+
* an error.
|
|
115
|
+
* @async
|
|
116
|
+
* @param key of the stored object
|
|
117
|
+
* @param field to increment
|
|
118
|
+
* @param amount by which to increment (can be negative, defaults to 1)
|
|
119
|
+
* @param options optionally set a TTL for this row
|
|
120
|
+
* @returns the value of the field after incrementing
|
|
121
|
+
*/
|
|
122
|
+
increment(key: string, field: string, amount?: number, options?: KVRowOptions): Promise<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Atomically increment the values of multiple numeric fields. If the object or fields did not previously exist, the
|
|
125
|
+
* resulting fields will be set to their respective given amount. If any of the fields does already exist but is not a
|
|
126
|
+
* number, this will result in an error.
|
|
127
|
+
* @async
|
|
128
|
+
* @param key of the stored object
|
|
129
|
+
* @param fieldAmounts hash of fields to amounts by which to increment (can be negative)
|
|
130
|
+
* @param options optionally set a TTL for this row
|
|
131
|
+
* @returns hash of fields to values after incrementing
|
|
132
|
+
*/
|
|
133
|
+
incrementMulti(key: string, fieldAmounts: MultiValue<number>, options?: KVRowOptions): Promise<MultiValue<number>>;
|
|
134
|
+
/**
|
|
135
|
+
* Atomically retrieve and remove the *first* element from a list. If the object or field does not exist or is empty,
|
|
136
|
+
* the result will be `undefined`. Calling this method on a non-existent object will not cause it to be created. If
|
|
137
|
+
* the field exists but is not a list, this will result in an error.
|
|
138
|
+
* @async
|
|
139
|
+
* @param key of the stored object
|
|
140
|
+
* @param field that holds the list
|
|
141
|
+
* @returns the first element of the list, if available, otherwise `undefined`
|
|
142
|
+
*/
|
|
143
|
+
shift<T extends Value>(key: string, field: string): Promise<T | undefined>;
|
|
144
|
+
/**
|
|
145
|
+
* Atomically retrieve and remove *up to* the given number of elements from the *front* of the given lists. If the
|
|
146
|
+
* object or fields do not exist or are empty, the result of each missing field will be an empty array. Calling this
|
|
147
|
+
* method on a non-existent object will not cause it to be created. If any field exists but is not a list, this will
|
|
148
|
+
* result in an error.
|
|
149
|
+
* @async
|
|
150
|
+
* @param key of the stored object
|
|
151
|
+
* @param fieldCounts hash of fields to number of elements to retrieve and remove
|
|
152
|
+
* @returns hash of fields to array of list elements
|
|
153
|
+
*/
|
|
154
|
+
shiftMulti<T extends Value>(key: string, fieldCounts: MultiValue<number>): Promise<MultiValue<T[]>>;
|
|
155
|
+
/**
|
|
156
|
+
* Atomically insert an element at the *front* of a list. If the object or field does not exist, it will be created
|
|
157
|
+
* with a list consisting of the given element. If the field exists but is not a list, this will result in an error.
|
|
158
|
+
* @async
|
|
159
|
+
* @param key of the stored object
|
|
160
|
+
* @param field that holds the list
|
|
161
|
+
* @param value to insert
|
|
162
|
+
*/
|
|
163
|
+
unshift<T extends Value>(key: string, field: string, value: T): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Atomically insert the given arrays of elements at the *front* of the given lists. If the object or fields do not
|
|
166
|
+
* exist, they will be created from the given arrays. If any field exists but is not a list, this will result in an
|
|
167
|
+
* error.
|
|
168
|
+
* @async
|
|
169
|
+
* @param key of the stored object
|
|
170
|
+
* @param fieldValues hash of fields to array of values to insert
|
|
171
|
+
*/
|
|
172
|
+
unshiftMulti<T extends Value>(key: string, fieldValues: MultiValue<T[]>): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Retrieve (without removing) the first element from a list. If the object or field does not exist, is empty, or is
|
|
175
|
+
* not a list, the result will be `undefined`.
|
|
176
|
+
* @async
|
|
177
|
+
* @param key of the stored object
|
|
178
|
+
* @param field that holds the list
|
|
179
|
+
* @returns the first element of the list, if available, otherwise `undefined`
|
|
180
|
+
*/
|
|
181
|
+
peek<T extends Value>(key: string, field: string): Promise<T | undefined>;
|
|
182
|
+
/**
|
|
183
|
+
* Retrieve (without removing) *up to* the given number of elements from the *front* of the given lists. If the object
|
|
184
|
+
* or fields do not exist, are empty, or are not lists, the result of each missing field will be an empty array.
|
|
185
|
+
* @async
|
|
186
|
+
* @param key of the stored object
|
|
187
|
+
* @param fieldCounts hash of fields to number of elements to retrieve
|
|
188
|
+
* @returns hash of fields to array of list elements
|
|
189
|
+
*/
|
|
190
|
+
peekMulti<T extends Value>(key: string, fieldCounts: MultiValue<number>): Promise<MultiValue<T[]>>;
|
|
191
|
+
/**
|
|
192
|
+
* Atomically append an element to the *end* of a list. If the object or field does not exist, it will be created
|
|
193
|
+
* with a list consisting of the given element. If the field exists but is not a list, this will result in an error.
|
|
194
|
+
* @async
|
|
195
|
+
* @param key of the stored object
|
|
196
|
+
* @param field that holds the list
|
|
197
|
+
* @param value to append
|
|
198
|
+
*/
|
|
199
|
+
append<T extends Value>(key: string, field: string, value: T): Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Atomically append the given arrays of elements to the *end* of the given lists. If the object or fields do not
|
|
202
|
+
* exist, they will be created from the given arrays. If any field exists but is not a list, this will result in an
|
|
203
|
+
* error.
|
|
204
|
+
* @async
|
|
205
|
+
* @param key of the stored object
|
|
206
|
+
* @param fieldValues hash of fields to array of values to append
|
|
207
|
+
*/
|
|
208
|
+
appendMulti<T extends Value>(key: string, fieldValues: MultiValue<T[]>): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Atomically adds a value to a NumberSet. If the object or field does not exist, it will be created with a NumberSet
|
|
211
|
+
* containing the given element. If the field exists but is not a NumberSet, this will result in an error.
|
|
212
|
+
* @param key of the stored object
|
|
213
|
+
* @param field that holds the NumberSet
|
|
214
|
+
* @param value to add
|
|
215
|
+
* @returns `true` if the value was newly added, `false` if it was already a member of the set
|
|
216
|
+
*/
|
|
217
|
+
addNumber(key: string, field: string, value: number): Promise<boolean>;
|
|
218
|
+
/**
|
|
219
|
+
* Atomically adds the given arrays of values to the given NumberSet fields. If the object or fields do not exist,
|
|
220
|
+
* they will be created from the given arrays. If any field exists but is not a NumberSet, this will result in an
|
|
221
|
+
* error.
|
|
222
|
+
* @param key of the stored object
|
|
223
|
+
* @param fieldValues hash of fields to array of values to add
|
|
224
|
+
* @returns hash of fields to NumberSet containing only the values that were newly added (any values that already
|
|
225
|
+
* existed in the target NumberSet will not exist in the return value)
|
|
226
|
+
*/
|
|
227
|
+
addNumberMulti(key: string, fieldValues: MultiValue<number[]>): Promise<MultiValue<NumberSet>>;
|
|
228
|
+
/**
|
|
229
|
+
* Atomically removes a value from a NumberSet. Calling this method on a non-existent object will not cause it to
|
|
230
|
+
* be created. If the field exists but is not a NumberSet, this will result in an error.
|
|
231
|
+
* @param key of the stored object
|
|
232
|
+
* @param field that holds the NumberSet
|
|
233
|
+
* @param value to remove
|
|
234
|
+
* @returns `true` if the value was removed, `false` if it was not a member of the set
|
|
235
|
+
*/
|
|
236
|
+
removeNumber(key: string, field: string, value: number): Promise<boolean>;
|
|
237
|
+
/**
|
|
238
|
+
* Atomically removes the given arrays of values from the given NumberSet fields. Calling this method on a
|
|
239
|
+
* non-existent object will not cause it to be created. If any field exists but is not a NumberSet, this will result
|
|
240
|
+
* in an error.
|
|
241
|
+
* @param key of the stored object
|
|
242
|
+
* @param fieldValues hash of fields to array of values to remove
|
|
243
|
+
* @returns hash of fields to NumberSet containing only the values that were removed (any values that did not exist in
|
|
244
|
+
* the target NumberSet will not exist in the return value)
|
|
245
|
+
*/
|
|
246
|
+
removeNumberMulti(key: string, fieldValues: MultiValue<number[]>): Promise<MultiValue<NumberSet>>;
|
|
247
|
+
/**
|
|
248
|
+
* Checks if a value exists in a NumberSet. Calling this method on a non-existent object will not cause it to be
|
|
249
|
+
* created. If the field exists but is not a NumberSet, this will result in an error.
|
|
250
|
+
* @param key of the stored object
|
|
251
|
+
* @param field that holds the NumberSet
|
|
252
|
+
* @param value to check
|
|
253
|
+
* @returns `true` if the value is a member of the set, `false` if it is not
|
|
254
|
+
*/
|
|
255
|
+
hasNumber(key: string, field: string, value: number): Promise<boolean>;
|
|
256
|
+
/**
|
|
257
|
+
* Checks if the given arrays of values exist in the given NumberSet fields. Calling this method on a non-existent
|
|
258
|
+
* object will not cause it to be created. If any field exists but is not a NumberSet, this will result in an error.
|
|
259
|
+
* @param key of the stored object
|
|
260
|
+
* @param fieldValues hash of fields to array of values to check
|
|
261
|
+
* @returns hash of fields to NumberSet containing only the values that exist in the target NumberSet
|
|
262
|
+
*/
|
|
263
|
+
hasNumberMulti(key: string, fieldValues: MultiValue<number[]>): Promise<MultiValue<NumberSet>>;
|
|
264
|
+
/**
|
|
265
|
+
* Atomically adds a value to a StringSet. If the object or field does not exist, it will be created with a StringSet
|
|
266
|
+
* containing the given element. If the field exists but is not a StringSet, this will result in an error.
|
|
267
|
+
* @param key of the stored object
|
|
268
|
+
* @param field that holds the StringSet
|
|
269
|
+
* @param value to add
|
|
270
|
+
* @returns `true` if the value was newly added, `false` if it was already a member of the set
|
|
271
|
+
*/
|
|
272
|
+
addString(key: string, field: string, value: string): Promise<boolean>;
|
|
273
|
+
/**
|
|
274
|
+
* Atomically adds the given arrays of values to the given StringSet fields. If the object or fields do not exist,
|
|
275
|
+
* they will be created from the given arrays. If any field exists but is not a StringSet, this will result in an
|
|
276
|
+
* error.
|
|
277
|
+
* @param key of the stored object
|
|
278
|
+
* @param fieldValues hash of fields to array of values to add
|
|
279
|
+
* @returns hash of fields to StringSet containing only the values that were newly added (any values that already
|
|
280
|
+
* existed in the target StringSet will not exist in the return value)
|
|
281
|
+
*/
|
|
282
|
+
addStringMulti(key: string, fieldValues: MultiValue<string[]>): Promise<MultiValue<StringSet>>;
|
|
283
|
+
/**
|
|
284
|
+
* Atomically removes a value from a StringSet. Calling this method on a non-existent object will not cause it to
|
|
285
|
+
* be created. If the field exists but is not a StringSet, this will result in an error.
|
|
286
|
+
* @param key of the stored object
|
|
287
|
+
* @param field that holds the StringSet
|
|
288
|
+
* @param value to remove
|
|
289
|
+
* @returns `true` if the value was removed, `false` if it was not a member of the set
|
|
290
|
+
*/
|
|
291
|
+
removeString(key: string, field: string, value: string): Promise<boolean>;
|
|
292
|
+
/**
|
|
293
|
+
* Atomically removes the given arrays of values from the given StringSet fields. Calling this method on a
|
|
294
|
+
* non-existent object will not cause it to be created. If any field exists but is not a StringSet, this will result
|
|
295
|
+
* in an error.
|
|
296
|
+
* @param key of the stored object
|
|
297
|
+
* @param fieldValues hash of fields to array of values to remove
|
|
298
|
+
* @returns hash of fields to StringSet containing only the values that were removed (any values that did not exist in
|
|
299
|
+
* the target StringSet will not exist in the return value)
|
|
300
|
+
*/
|
|
301
|
+
removeStringMulti(key: string, fieldValues: MultiValue<string[]>): Promise<MultiValue<StringSet>>;
|
|
302
|
+
/**
|
|
303
|
+
* Checks if a value exists in a StringSet. Calling this method on a non-existent object will not cause it to be
|
|
304
|
+
* created. If the field exists but is not a StringSet, this will result in an error.
|
|
305
|
+
* @param key of the stored object
|
|
306
|
+
* @param field that holds the StringSet
|
|
307
|
+
* @param value to check
|
|
308
|
+
* @returns `true` if the value is a member of the set, `false` if it is not
|
|
309
|
+
*/
|
|
310
|
+
hasString(key: string, field: string, value: string): Promise<boolean>;
|
|
311
|
+
/**
|
|
312
|
+
* Checks if the given arrays of values exist in the given StringSet fields. Calling this method on a non-existent
|
|
313
|
+
* object will not cause it to be created. If any field exists but is not a StringSet, this will result in an error.
|
|
314
|
+
* @param key of the stored object
|
|
315
|
+
* @param fieldValues hash of fields to array of values to check
|
|
316
|
+
* @returns hash of fields to StringSet containing only the values that exist in the target StringSet
|
|
317
|
+
*/
|
|
318
|
+
hasStringMulti(key: string, fieldValues: MultiValue<string[]>): Promise<MultiValue<StringSet>>;
|
|
319
|
+
}
|
|
320
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kvstore.js","sourceRoot":"","sources":["../../../src/types/kvstore.ts"],"names":[],"mappings":";AAAA,8CAA8C;AAC9C,uDAAuD"}
|