@owlmeans/state 0.1.18-rc.8 → 0.1.18
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 +173 -68
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/state/SKILL.md +137 -58
- package/build/consts.local.d.ts +10 -0
- package/build/consts.local.d.ts.map +1 -0
- package/build/consts.local.js +10 -0
- package/build/consts.local.js.map +1 -0
- package/build/errors.d.ts +12 -5
- package/build/errors.d.ts.map +1 -1
- package/build/errors.js +16 -13
- package/build/errors.js.map +1 -1
- package/build/helper.d.ts +16 -0
- package/build/helper.d.ts.map +1 -0
- package/build/helper.js +14 -0
- package/build/helper.js.map +1 -0
- package/build/index.d.ts +3 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/resource.d.ts +12 -5
- package/build/resource.d.ts.map +1 -1
- package/build/resource.js +317 -207
- package/build/resource.js.map +1 -1
- package/build/types.d.ts +91 -50
- package/build/types.d.ts.map +1 -1
- package/build/types.local.d.ts +15 -0
- package/build/types.local.d.ts.map +1 -0
- package/build/types.local.js +2 -0
- package/build/types.local.js.map +1 -0
- package/build/utils/criteria.d.ts.map +1 -1
- package/build/utils/criteria.js.map +1 -1
- package/build/utils/model.d.ts +10 -2
- package/build/utils/model.d.ts.map +1 -1
- package/build/utils/model.js +26 -22
- package/build/utils/model.js.map +1 -1
- package/build/utils/types.d.ts +15 -0
- package/build/utils/types.d.ts.map +1 -0
- package/build/utils/types.js +2 -0
- package/build/utils/types.js.map +1 -0
- package/package.json +4 -4
- package/src/consts.local.ts +11 -0
- package/src/errors.ts +16 -13
- package/src/helper.ts +17 -0
- package/src/index.ts +3 -2
- package/src/resource.ts +359 -241
- package/src/types.local.ts +16 -0
- package/src/types.ts +98 -55
- package/src/utils/model.ts +35 -28
- package/src/utils/types.ts +15 -0
- package/tests/resource.spec.ts +347 -90
- package/build/.gitkeep +0 -0
- package/src/consts.ts +0 -3
- package/src/utils/criteria.ts +0 -252
- package/src/utils/index.ts +0 -3
- package/tests/criteria.spec.ts +0 -121
package/build/errors.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { ResourceError } from '@owlmeans/resource';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare class
|
|
2
|
+
/**
|
|
3
|
+
* The resource was asked for something its {@link StateConfig} does not allow. Both cases are
|
|
4
|
+
* wiring mistakes rather than missing data, so they throw instead of answering with nothing.
|
|
5
|
+
*/
|
|
6
|
+
export declare class StateConfigError extends ResourceError {
|
|
7
7
|
static typeName: string;
|
|
8
|
+
/**
|
|
9
|
+
* A record was addressed without an id on a resource that holds many of them. Only a `single`
|
|
10
|
+
* resource has a record that needs no naming.
|
|
11
|
+
*/
|
|
12
|
+
static readonly NonSingle: string;
|
|
13
|
+
/** A write carried no value for the resource's id field, and nothing here mints one. */
|
|
14
|
+
static readonly NoId: string;
|
|
8
15
|
constructor(msg: string);
|
|
9
16
|
}
|
|
10
17
|
//# sourceMappingURL=errors.d.ts.map
|
package/build/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,OAAuB,QAAQ,SAAyC;IAExE;;;OAGG;IACH,gBAAuB,SAAS,EAAE,MAAM,CAAe;IAEvD,wFAAwF;IACxF,gBAAuB,IAAI,EAAE,MAAM,CAAU;IAE7C,YAAY,GAAG,EAAE,MAAM,EAGtB;CACF"}
|
package/build/errors.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { ResourceError } from '@owlmeans/resource';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* The resource was asked for something its {@link StateConfig} does not allow. Both cases are
|
|
4
|
+
* wiring mistakes rather than missing data, so they throw instead of answering with nothing.
|
|
5
|
+
*/
|
|
6
|
+
export class StateConfigError extends ResourceError {
|
|
7
|
+
static typeName = `${ResourceError.typeName}StateConfig`;
|
|
8
|
+
/**
|
|
9
|
+
* A record was addressed without an id on a resource that holds many of them. Only a `single`
|
|
10
|
+
* resource has a record that needs no naming.
|
|
11
|
+
*/
|
|
12
|
+
static NonSingle = 'non-single';
|
|
13
|
+
/** A write carried no value for the resource's id field, and nothing here mints one. */
|
|
14
|
+
static NoId = 'no-id';
|
|
4
15
|
constructor(msg) {
|
|
5
|
-
super(`
|
|
6
|
-
this.type =
|
|
16
|
+
super(`state-config:${msg}`);
|
|
17
|
+
this.type = StateConfigError.typeName;
|
|
7
18
|
}
|
|
8
19
|
}
|
|
9
|
-
|
|
10
|
-
static typeName = `${StateToolingError.typeName}Listener`;
|
|
11
|
-
constructor(msg) {
|
|
12
|
-
super(`listener:${msg}`);
|
|
13
|
-
this.type = StateListenerError.typeName;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
ResourceError.registerErrorClass(StateToolingError);
|
|
17
|
-
ResourceError.registerErrorClass(StateListenerError);
|
|
20
|
+
ResourceError.registerErrorClass(StateConfigError);
|
|
18
21
|
//# sourceMappingURL=errors.js.map
|
package/build/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;GAGG;AACH,MAAM,OAAO,gBAAiB,SAAQ,aAAa;IAC1C,MAAM,CAAU,QAAQ,GAAG,GAAG,aAAa,CAAC,QAAQ,aAAa,CAAA;IAExE;;;OAGG;IACI,MAAM,CAAU,SAAS,GAAW,YAAY,CAAA;IAEvD,wFAAwF;IACjF,MAAM,CAAU,IAAI,GAAW,OAAO,CAAA;IAE7C,YAAY,GAAW;QACrB,KAAK,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC,QAAQ,CAAA;IACvC,CAAC;CACF;AAED,aAAa,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ResourceRecord } from '@owlmeans/resource';
|
|
2
|
+
import type { StateAlias } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Name a state resource once, with the record type it holds attached:
|
|
5
|
+
*
|
|
6
|
+
* ```typescript
|
|
7
|
+
* export const TASKS = stateAlias<Task>('tasks')
|
|
8
|
+
* const tasks = context.getStateResource(TASKS) // StateResource<Task>
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* The handle is the string itself at runtime — the type rides along only so that every reader of
|
|
12
|
+
* the alias gets the record type without repeating it, and so that a mismatch is a compile error
|
|
13
|
+
* instead of a record shaped like nothing anyone expected.
|
|
14
|
+
*/
|
|
15
|
+
export declare const stateAlias: <T extends ResourceRecord>(alias: string) => StateAlias<T>;
|
|
16
|
+
//# sourceMappingURL=helper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,cAAc,SAAS,MAAM,KAAG,UAAU,CAAC,CAAC,CACzD,CAAA"}
|
package/build/helper.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Name a state resource once, with the record type it holds attached:
|
|
3
|
+
*
|
|
4
|
+
* ```typescript
|
|
5
|
+
* export const TASKS = stateAlias<Task>('tasks')
|
|
6
|
+
* const tasks = context.getStateResource(TASKS) // StateResource<Task>
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* The handle is the string itself at runtime — the type rides along only so that every reader of
|
|
10
|
+
* the alias gets the record type without repeating it, and so that a mismatch is a compile error
|
|
11
|
+
* instead of a record shaped like nothing anyone expected.
|
|
12
|
+
*/
|
|
13
|
+
export const stateAlias = (alias) => alias;
|
|
14
|
+
//# sourceMappingURL=helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAA2B,KAAa,EAAiB,EAAE,CACnF,KAAsB,CAAA"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type * from './types.js';
|
|
2
|
-
export * from './consts.js';
|
|
3
2
|
export * from './errors.js';
|
|
3
|
+
export * from './helper.js';
|
|
4
4
|
export * from './resource.js';
|
|
5
|
-
export * from './utils/
|
|
5
|
+
export * from './utils/model.js';
|
|
6
|
+
export type * from './utils/types.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAE/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAE/B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,mBAAmB,kBAAkB,CAAA"}
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA"}
|
package/build/resource.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import
|
|
3
|
-
import type {
|
|
4
|
-
export declare const createStateResource: <
|
|
5
|
-
|
|
1
|
+
import { type BasicConfig as Config, type BasicContext as Context } from '@owlmeans/context';
|
|
2
|
+
import { type ResourceRecord } from '@owlmeans/resource';
|
|
3
|
+
import type { StateConfig, StateResource, StateResourceAppend } from './types.js';
|
|
4
|
+
export declare const createStateResource: <T extends ResourceRecord>(alias?: string, cfg?: StateConfig<T>) => StateResource<T>;
|
|
5
|
+
/**
|
|
6
|
+
* Register a state resource on the context and expose `getStateResource`.
|
|
7
|
+
*
|
|
8
|
+
* Idempotent: appending the same alias twice keeps the resource that is already there, so a
|
|
9
|
+
* setup that runs more than once does not drop what the store has collected. The first alias
|
|
10
|
+
* appended is the one `getStateResource()` answers with when it is called without one.
|
|
11
|
+
*/
|
|
12
|
+
export declare const appendStateResource: <C extends Config, T extends Context<C>, R extends ResourceRecord = ResourceRecord>(ctx: T, alias?: string, cfg?: StateConfig<R>) => T & StateResourceAppend;
|
|
6
13
|
//# sourceMappingURL=resource.d.ts.map
|
package/build/resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,WAAW,IAAI,MAAM,EAAE,KAAK,YAAY,IAAI,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC9G,OAAO,EAAqI,KAAK,cAAc,EAAwE,MAAM,oBAAoB,CAAA;AAGjQ,OAAO,KAAK,EACV,WAAW,EAA0B,aAAa,EAAE,mBAAmB,EACxE,MAAM,YAAY,CAAA;AAQnB,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,cAAc,UACnD,MAAM,QAAgB,WAAW,CAAC,CAAC,CAAC,KAC1C,aAAa,CAAC,CAAC,CA8ZjB,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,cAAc,GAAG,cAAc,OAC5E,CAAC,UAAS,MAAM,QAAgB,WAAW,CAAC,CAAC,CAAC,KAAG,CAAC,GAAG,mBAa3D,CAAA"}
|