@app-compose/coda 3.0.0-beta.7

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 The grlt-hub Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # @app-compose/coda
2
+
3
+ Helper utilities for [App-Compose](https://app-compose.dev). Named helpers for Task and Wire patterns you'd otherwise spell out by hand.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/%40app-compose%2Fcoda?color=orange)](https://www.npmjs.com/package/@app-compose/coda)
6
+ ![npm license](https://img.shields.io/npm/l/%40app-compose%2Fcoda?color=blue)
7
+ ![bundle size](https://deno.bundlejs.com/badge?q=@app-compose/coda&treeshake=[*])
8
+ ![zero dependencies](https://img.shields.io/badge/dependencies-0-blue)
9
+ [![npm provenance](https://img.shields.io/badge/provenance-yes-brightgreen?logo=npm)](https://www.npmjs.com/package/@app-compose/coda)
10
+ [![llms.txt](https://img.shields.io/badge/llms.txt-ready-blue)](https://app-compose.dev/_llms-txt/coda.txt)
11
+
12
+ [Docs](https://app-compose.dev/coda) | [App-Compose](https://app-compose.dev)
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install --save-exact @app-compose/coda
18
+ ```
19
+
20
+ Requires `@app-compose/core` 3+.
21
+
22
+ ## Utilities
23
+
24
+ | Name | Description |
25
+ | ------------------------------------------- | --------------------------------------------------------------------------- |
26
+ | [debug](https://app-compose.dev/coda/debug) | A runtime inspection Task — logs Tasks, Tags, and Spots to the console. |
27
+ | [every](https://app-compose.dev/coda/every) | All-of quantifier for Tasks, Tags, and Spots — by predicate or Task status. |
28
+ | [some](https://app-compose.dev/coda/some) | Any-of quantifier for Tasks, Tags, and Spots — by predicate or Task status. |
29
+ | [not](https://app-compose.dev/coda/not) | Inverts a Spot into its boolean opposite. |
30
+ | [when](https://app-compose.dev/coda/when) | Wraps `every`, `some`, and `not` into `{ context, fn: Boolean }`. |
31
+
32
+ ## AI tools
33
+
34
+ coda ships an LLM-friendly subset of the docs.
35
+
36
+ ### Cursor
37
+
38
+ 1. Open chat and type `@docs`
39
+ 2. Click **Add new doc**
40
+ 3. Paste the URL and confirm:
41
+
42
+ ```
43
+ https://app-compose.dev/_llms-txt/coda.txt
44
+ ```
45
+
46
+ ### Claude / ChatGPT / Copilot
47
+
48
+ Paste this URL into the chat — most assistants accept URLs as context:
49
+
50
+ ```
51
+ https://app-compose.dev/_llms-txt/coda.txt
52
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,118 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _app_compose_core = require("@app-compose/core");
3
+ //#region src/shared.ts
4
+ const LIBRARY_NAME = "[coda]";
5
+ //#endregion
6
+ //#region src/debug/index.ts
7
+ const normalize = (head, tail) => !_app_compose_core.is.task(head) && !_app_compose_core.is.tag(head) && "name" in head ? {
8
+ options: head,
9
+ targets: tail
10
+ } : {
11
+ options: { name: "" },
12
+ targets: [head, ...tail]
13
+ };
14
+ function debug(...args) {
15
+ const [head, ...tail] = args;
16
+ const { options, targets } = normalize(head, tail);
17
+ const context = targets.map((target) => _app_compose_core.is.task(target) ? {
18
+ title: (0, _app_compose_core.literal)(`[Task]: ${target.name}`),
19
+ output: (0, _app_compose_core.shape)({
20
+ status: (0, _app_compose_core.optional)(target.status),
21
+ result: (0, _app_compose_core.optional)(target.result),
22
+ error: (0, _app_compose_core.optional)(target.error)
23
+ })
24
+ } : _app_compose_core.is.tag(target) ? {
25
+ title: (0, _app_compose_core.literal)(`[Tag]: ${target.name}`),
26
+ output: (0, _app_compose_core.optional)(target.value)
27
+ } : {
28
+ title: (0, _app_compose_core.literal)("[Spot]"),
29
+ output: (0, _app_compose_core.optional)(target)
30
+ });
31
+ const taskName = `${LIBRARY_NAME} debug ${options.name}`.trimEnd();
32
+ return (0, _app_compose_core.createTask)({
33
+ name: taskName,
34
+ run: {
35
+ context,
36
+ fn: (list) => {
37
+ console.groupCollapsed(taskName);
38
+ for (const target of list) {
39
+ console.group(target.title);
40
+ console.info(target.output);
41
+ console.groupEnd();
42
+ }
43
+ console.groupEnd();
44
+ }
45
+ }
46
+ });
47
+ }
48
+ //#endregion
49
+ //#region src/createQuantifier/index.ts
50
+ const createQuantifier = (mode) => {
51
+ const quantifier = (list, predicate) => (0, _app_compose_core.shape)(list.map((item) => _app_compose_core.is.tag(item) ? item.value : _app_compose_core.is.task(item) ? {
52
+ result: item.result,
53
+ status: item.status,
54
+ error: (0, _app_compose_core.optional)(item.error)
55
+ } : item), (values) => values[mode](predicate));
56
+ quantifier.status = (items, status) => (0, _app_compose_core.shape)(items.map((item) => _app_compose_core.is.task(item) ? item.status : item), (statuses) => statuses[mode]((s) => s === status));
57
+ return quantifier;
58
+ };
59
+ //#endregion
60
+ //#region src/every/index.ts
61
+ const every = createQuantifier("every");
62
+ //#endregion
63
+ //#region src/some/index.ts
64
+ const some = createQuantifier("some");
65
+ //#endregion
66
+ //#region src/not/index.ts
67
+ const not = (value) => (0, _app_compose_core.shape)(value, (x) => !x);
68
+ //#endregion
69
+ //#region src/when/index.ts
70
+ const whenEvery = (list, predicate) => ({
71
+ context: every(list, predicate),
72
+ fn: Boolean
73
+ });
74
+ whenEvery.status = (items, status) => ({
75
+ context: every.status(items, status),
76
+ fn: Boolean
77
+ });
78
+ const whenSome = (list, predicate) => ({
79
+ context: some(list, predicate),
80
+ fn: Boolean
81
+ });
82
+ whenSome.status = (items, status) => ({
83
+ context: some.status(items, status),
84
+ fn: Boolean
85
+ });
86
+ const whenNot = (spot) => ({
87
+ context: not(spot),
88
+ fn: Boolean
89
+ });
90
+ const whenNotEvery = (list, predicate) => ({
91
+ context: not(every(list, predicate)),
92
+ fn: Boolean
93
+ });
94
+ whenNotEvery.status = (items, status) => ({
95
+ context: not(every.status(items, status)),
96
+ fn: Boolean
97
+ });
98
+ const whenNotSome = (list, predicate) => ({
99
+ context: not(some(list, predicate)),
100
+ fn: Boolean
101
+ });
102
+ whenNotSome.status = (items, status) => ({
103
+ context: not(some.status(items, status)),
104
+ fn: Boolean
105
+ });
106
+ whenNot.every = whenNotEvery;
107
+ whenNot.some = whenNotSome;
108
+ const when = {
109
+ every: whenEvery,
110
+ some: whenSome,
111
+ not: whenNot
112
+ };
113
+ //#endregion
114
+ exports.debug = debug;
115
+ exports.every = every;
116
+ exports.not = not;
117
+ exports.some = some;
118
+ exports.when = when;
@@ -0,0 +1,51 @@
1
+ import { Spot, SpotValue, Tag, Task, TaskResult, TaskStatus } from "@app-compose/core";
2
+
3
+ //#region src/debug/index.d.ts
4
+ type DebugOptions = {
5
+ name: Task<unknown>["name"];
6
+ };
7
+ type DebugTarget = Task<unknown> | Tag<unknown> | Spot<unknown>;
8
+ declare function debug(opts: DebugOptions, target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
9
+ declare function debug(target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
10
+ //#endregion
11
+ //#region src/createQuantifier/index.d.ts
12
+ type TaskValue<T> = {
13
+ result: TaskResult<T>;
14
+ status: TaskStatus;
15
+ error: SpotValue<Task<T>["error"]>;
16
+ };
17
+ type ItemValue<T> = T extends Task<unknown> ? TaskValue<T> : T extends Tag<infer V> ? V : T extends Spot<infer V> ? V : never;
18
+ type Quantifier<R> = {
19
+ <const List extends readonly (Task<unknown> | Tag<unknown> | Spot<unknown>)[]>(list: List, predicate: (values: ItemValue<List[number]>) => boolean): R;
20
+ status: <const Items extends readonly (Task<unknown> | Spot<TaskStatus | undefined>)[]>(items: Items, status: TaskStatus) => R;
21
+ };
22
+ //#endregion
23
+ //#region src/every/index.d.ts
24
+ declare const every: Quantifier<import("@app-compose/core").Spot<boolean>>;
25
+ //#endregion
26
+ //#region src/some/index.d.ts
27
+ declare const some: Quantifier<import("@app-compose/core").Spot<boolean>>;
28
+ //#endregion
29
+ //#region src/not/index.d.ts
30
+ type Not = (value: Spot<unknown>) => Spot<boolean>;
31
+ declare const not: Not;
32
+ //#endregion
33
+ //#region src/when/index.d.ts
34
+ type Result = {
35
+ context: Spot<boolean>;
36
+ fn: typeof Boolean;
37
+ };
38
+ type WhenQuantifier = Quantifier<Result>;
39
+ type WhenNot = {
40
+ (spot: Parameters<Not>[0]): Result;
41
+ every: WhenQuantifier;
42
+ some: WhenQuantifier;
43
+ };
44
+ declare const when: {
45
+ every: WhenQuantifier;
46
+ some: WhenQuantifier;
47
+ not: WhenNot;
48
+ };
49
+ //#endregion
50
+ export { debug, every, not, some, when };
51
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/debug/index.ts","../src/createQuantifier/index.ts","../src/every/index.ts","../src/some/index.ts","../src/not/index.ts","../src/when/index.ts"],"mappings":";;;KAGK,YAAA;EACH,IAAA,EAAM,IAAI;AAAA;AAAA,KAGP,WAA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L,IAAA,EAAI,cAAA;EACJ,GAAA,EAAG,OAAA;AAAA"}
@@ -0,0 +1,51 @@
1
+ import { Spot, SpotValue, Tag, Task, TaskResult, TaskStatus } from "@app-compose/core";
2
+
3
+ //#region src/debug/index.d.ts
4
+ type DebugOptions = {
5
+ name: Task<unknown>["name"];
6
+ };
7
+ type DebugTarget = Task<unknown> | Tag<unknown> | Spot<unknown>;
8
+ declare function debug(opts: DebugOptions, target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
9
+ declare function debug(target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
10
+ //#endregion
11
+ //#region src/createQuantifier/index.d.ts
12
+ type TaskValue<T> = {
13
+ result: TaskResult<T>;
14
+ status: TaskStatus;
15
+ error: SpotValue<Task<T>["error"]>;
16
+ };
17
+ type ItemValue<T> = T extends Task<unknown> ? TaskValue<T> : T extends Tag<infer V> ? V : T extends Spot<infer V> ? V : never;
18
+ type Quantifier<R> = {
19
+ <const List extends readonly (Task<unknown> | Tag<unknown> | Spot<unknown>)[]>(list: List, predicate: (values: ItemValue<List[number]>) => boolean): R;
20
+ status: <const Items extends readonly (Task<unknown> | Spot<TaskStatus | undefined>)[]>(items: Items, status: TaskStatus) => R;
21
+ };
22
+ //#endregion
23
+ //#region src/every/index.d.ts
24
+ declare const every: Quantifier<import("@app-compose/core").Spot<boolean>>;
25
+ //#endregion
26
+ //#region src/some/index.d.ts
27
+ declare const some: Quantifier<import("@app-compose/core").Spot<boolean>>;
28
+ //#endregion
29
+ //#region src/not/index.d.ts
30
+ type Not = (value: Spot<unknown>) => Spot<boolean>;
31
+ declare const not: Not;
32
+ //#endregion
33
+ //#region src/when/index.d.ts
34
+ type Result = {
35
+ context: Spot<boolean>;
36
+ fn: typeof Boolean;
37
+ };
38
+ type WhenQuantifier = Quantifier<Result>;
39
+ type WhenNot = {
40
+ (spot: Parameters<Not>[0]): Result;
41
+ every: WhenQuantifier;
42
+ some: WhenQuantifier;
43
+ };
44
+ declare const when: {
45
+ every: WhenQuantifier;
46
+ some: WhenQuantifier;
47
+ not: WhenNot;
48
+ };
49
+ //#endregion
50
+ export { debug, every, not, some, when };
51
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/debug/index.ts","../src/createQuantifier/index.ts","../src/every/index.ts","../src/some/index.ts","../src/not/index.ts","../src/when/index.ts"],"mappings":";;;KAGK,YAAA;EACH,IAAA,EAAM,IAAI;AAAA;AAAA,KAGP,WAAA,GAAc,IAAA,YAAgB,GAAA,YAAe,IAAA;AAAA,iBAOzC,KAAA,CAAM,IAAA,EAAM,YAAA,EAAc,MAAA,EAAQ,WAAA,KAAgB,OAAA,EAAS,WAAA,KAAgB,IAAA;AAAA,iBAC3E,KAAA,CAAM,MAAA,EAAQ,WAAA,KAAgB,OAAA,EAAS,WAAA,KAAgB,IAAA;;;KCH3D,SAAA;EAAiB,MAAA,EAAQ,UAAA,CAAW,CAAA;EAAI,MAAA,EAAQ,UAAA;EAAY,KAAA,EAAO,SAAA,CAAU,IAAA,CAAK,CAAA;AAAA;AAAA,KAElF,SAAA,MACH,CAAA,SAAU,IAAA,YAAgB,SAAA,CAAU,CAAA,IAAK,CAAA,SAAU,GAAA,YAAe,CAAA,GAAI,CAAA,SAAU,IAAA,YAAgB,CAAA;AAAA,KAE7F,UAAA;EAAA,8BAC2B,IAAA,YAAgB,GAAA,YAAe,IAAA,cAC3D,IAAA,EAAM,IAAA,EACN,SAAA,GAAY,MAAA,EAAQ,SAAA,CAAU,IAAA,wBAC7B,CAAA;EACH,MAAA,iCAAuC,IAAA,YAAgB,IAAA,CAAK,UAAA,kBAC1D,KAAA,EAAO,KAAA,EACP,MAAA,EAAQ,UAAA,KACL,CAAA;AAAA;;;cCvBM,KAAA,EAAiC,UAA5B,6BAAA,IAAA;;;cCAL,IAAA,EAA+B,UAA3B,6BAAA,IAAA;;;KCAZ,GAAA,IAAO,KAAA,EAAO,IAAA,cAAkB,IAAI;AAAA,cAEnC,GAAA,EAAK,GAAwC;;;KCE9C,MAAA;EAAW,OAAA,EAAS,IAAA;EAAe,EAAA,SAAW,OAAO;AAAA;AAAA,KAErD,cAAA,GAAiB,UAAU,CAAC,MAAA;AAAA,KAQ5B,OAAA;EAAA,CACF,IAAA,EAAM,UAAA,CAAW,GAAA,OAAU,MAAA;EAC5B,KAAA,EAAO,cAAA;EACP,IAAA,EAAM,cAAA;AAAA;AAAA,cAcF,IAAA;EACJ,KAAA,EAAK,cAAA;EACL,IAAA,EAAI,cAAA;EACJ,GAAA,EAAG,OAAA;AAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,115 @@
1
+ import { createTask, is, literal, optional, shape } from "@app-compose/core";
2
+ //#region src/shared.ts
3
+ const LIBRARY_NAME = "[coda]";
4
+ //#endregion
5
+ //#region src/debug/index.ts
6
+ const normalize = (head, tail) => !is.task(head) && !is.tag(head) && "name" in head ? {
7
+ options: head,
8
+ targets: tail
9
+ } : {
10
+ options: { name: "" },
11
+ targets: [head, ...tail]
12
+ };
13
+ function debug(...args) {
14
+ const [head, ...tail] = args;
15
+ const { options, targets } = normalize(head, tail);
16
+ const context = targets.map((target) => is.task(target) ? {
17
+ title: literal(`[Task]: ${target.name}`),
18
+ output: shape({
19
+ status: optional(target.status),
20
+ result: optional(target.result),
21
+ error: optional(target.error)
22
+ })
23
+ } : is.tag(target) ? {
24
+ title: literal(`[Tag]: ${target.name}`),
25
+ output: optional(target.value)
26
+ } : {
27
+ title: literal("[Spot]"),
28
+ output: optional(target)
29
+ });
30
+ const taskName = `${LIBRARY_NAME} debug ${options.name}`.trimEnd();
31
+ return createTask({
32
+ name: taskName,
33
+ run: {
34
+ context,
35
+ fn: (list) => {
36
+ console.groupCollapsed(taskName);
37
+ for (const target of list) {
38
+ console.group(target.title);
39
+ console.info(target.output);
40
+ console.groupEnd();
41
+ }
42
+ console.groupEnd();
43
+ }
44
+ }
45
+ });
46
+ }
47
+ //#endregion
48
+ //#region src/createQuantifier/index.ts
49
+ const createQuantifier = (mode) => {
50
+ const quantifier = (list, predicate) => shape(list.map((item) => is.tag(item) ? item.value : is.task(item) ? {
51
+ result: item.result,
52
+ status: item.status,
53
+ error: optional(item.error)
54
+ } : item), (values) => values[mode](predicate));
55
+ quantifier.status = (items, status) => shape(items.map((item) => is.task(item) ? item.status : item), (statuses) => statuses[mode]((s) => s === status));
56
+ return quantifier;
57
+ };
58
+ //#endregion
59
+ //#region src/every/index.ts
60
+ const every = createQuantifier("every");
61
+ //#endregion
62
+ //#region src/some/index.ts
63
+ const some = createQuantifier("some");
64
+ //#endregion
65
+ //#region src/not/index.ts
66
+ const not = (value) => shape(value, (x) => !x);
67
+ //#endregion
68
+ //#region src/when/index.ts
69
+ const whenEvery = (list, predicate) => ({
70
+ context: every(list, predicate),
71
+ fn: Boolean
72
+ });
73
+ whenEvery.status = (items, status) => ({
74
+ context: every.status(items, status),
75
+ fn: Boolean
76
+ });
77
+ const whenSome = (list, predicate) => ({
78
+ context: some(list, predicate),
79
+ fn: Boolean
80
+ });
81
+ whenSome.status = (items, status) => ({
82
+ context: some.status(items, status),
83
+ fn: Boolean
84
+ });
85
+ const whenNot = (spot) => ({
86
+ context: not(spot),
87
+ fn: Boolean
88
+ });
89
+ const whenNotEvery = (list, predicate) => ({
90
+ context: not(every(list, predicate)),
91
+ fn: Boolean
92
+ });
93
+ whenNotEvery.status = (items, status) => ({
94
+ context: not(every.status(items, status)),
95
+ fn: Boolean
96
+ });
97
+ const whenNotSome = (list, predicate) => ({
98
+ context: not(some(list, predicate)),
99
+ fn: Boolean
100
+ });
101
+ whenNotSome.status = (items, status) => ({
102
+ context: not(some.status(items, status)),
103
+ fn: Boolean
104
+ });
105
+ whenNot.every = whenNotEvery;
106
+ whenNot.some = whenNotSome;
107
+ const when = {
108
+ every: whenEvery,
109
+ some: whenSome,
110
+ not: whenNot
111
+ };
112
+ //#endregion
113
+ export { debug, every, not, some, when };
114
+
115
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/shared.ts","../src/debug/index.ts","../src/createQuantifier/index.ts","../src/every/index.ts","../src/some/index.ts","../src/not/index.ts","../src/when/index.ts"],"sourcesContent":["const LIBRARY_NAME = \"[coda]\"\n\nexport { LIBRARY_NAME }\n","import { type Task, type Tag, type Spot, is, optional, literal, createTask, shape } from \"@app-compose/core\"\nimport { LIBRARY_NAME } from \"../shared\"\n\ntype DebugOptions = {\n name: Task<unknown>[\"name\"]\n}\n\ntype DebugTarget = Task<unknown> | Tag<unknown> | Spot<unknown>\n\nconst normalize = (head: DebugOptions | DebugTarget, tail: DebugTarget[]) =>\n !is.task(head) && !is.tag(head) && \"name\" in head\n ? { options: head, targets: tail }\n : { options: { name: \"\" }, targets: [head, ...tail] }\n\nfunction debug(opts: DebugOptions, target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>\nfunction debug(target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>\nfunction debug(\n ...args: [DebugOptions, DebugTarget, ...DebugTarget[]] | [DebugTarget, ...DebugTarget[]]\n): Task<unknown> {\n const [head, ...tail] = args\n const { options, targets } = normalize(head, tail as DebugTarget[])\n\n const context = targets.map((target) =>\n is.task(target)\n ? {\n title: literal(`[Task]: ${target.name}`),\n output: shape({\n status: optional(target.status),\n result: optional(target.result),\n error: optional(target.error),\n }),\n }\n : is.tag(target)\n ? { title: literal(`[Tag]: ${target.name}`), output: optional(target.value) }\n : { title: literal(\"[Spot]\"), output: optional(target) },\n )\n\n const taskName = `${LIBRARY_NAME} debug ${options.name}`.trimEnd()\n\n return createTask({\n name: taskName,\n run: {\n context,\n fn: (list) => {\n console.groupCollapsed(taskName)\n\n for (const target of list) {\n console.group(target.title)\n console.info(target.output)\n console.groupEnd()\n }\n\n console.groupEnd()\n },\n },\n })\n}\n\nexport { debug }\n","import {\n is,\n optional,\n shape,\n type Spot,\n type SpotValue,\n type Tag,\n type Task,\n type TaskResult,\n type TaskStatus,\n} from \"@app-compose/core\"\n\ntype TaskValue<T> = { result: TaskResult<T>; status: TaskStatus; error: SpotValue<Task<T>[\"error\"]> }\n\ntype ItemValue<T> =\n T extends Task<unknown> ? TaskValue<T> : T extends Tag<infer V> ? V : T extends Spot<infer V> ? V : never\n\ntype Quantifier<R> = {\n <const List extends readonly (Task<unknown> | Tag<unknown> | Spot<unknown>)[]>(\n list: List,\n predicate: (values: ItemValue<List[number]>) => boolean,\n ): R\n status: <const Items extends readonly (Task<unknown> | Spot<TaskStatus | undefined>)[]>(\n items: Items,\n status: TaskStatus,\n ) => R\n}\n\nconst createQuantifier = (mode: \"some\" | \"every\"): Quantifier<Spot<boolean>> => {\n const quantifier: Quantifier<Spot<boolean>> = (list, predicate) =>\n shape(\n list.map((item) =>\n is.tag(item)\n ? item.value\n : is.task(item)\n ? { result: item.result, status: item.status, error: optional(item.error) }\n : item,\n ),\n (values) => values[mode](predicate as (v: any) => boolean),\n )\n\n quantifier.status = (items, status) =>\n shape(\n items.map((item) => (is.task(item) ? item.status : item)),\n (statuses) => statuses[mode]((s) => s === status),\n )\n\n return quantifier\n}\n\nexport { createQuantifier, type Quantifier }\n","import { createQuantifier } from \"../createQuantifier\"\n\nexport const every = createQuantifier(\"every\")\n","import { createQuantifier } from \"../createQuantifier\"\n\nexport const some = createQuantifier(\"some\")\n","import { shape, type Spot } from \"@app-compose/core\"\n\ntype Not = (value: Spot<unknown>) => Spot<boolean>\n\nconst not: Not = (value) => shape(value, (x) => !x)\n\nexport { not, type Not }\n","import type { Spot } from \"@app-compose/core\"\nimport type { Quantifier } from \"../createQuantifier\"\nimport { every } from \"../every\"\nimport { not, type Not } from \"../not\"\nimport { some } from \"../some\"\n\ntype Result = { context: Spot<boolean>; fn: typeof Boolean }\n\ntype WhenQuantifier = Quantifier<Result>\n\nconst whenEvery: WhenQuantifier = (list, predicate) => ({ context: every(list, predicate), fn: Boolean })\nwhenEvery.status = (items, status) => ({ context: every.status(items, status), fn: Boolean })\n\nconst whenSome: WhenQuantifier = (list, predicate) => ({ context: some(list, predicate), fn: Boolean })\nwhenSome.status = (items, status) => ({ context: some.status(items, status), fn: Boolean })\n\ntype WhenNot = {\n (spot: Parameters<Not>[0]): Result\n every: WhenQuantifier\n some: WhenQuantifier\n}\n\nconst whenNot: WhenNot = (spot) => ({ context: not(spot), fn: Boolean })\n\nconst whenNotEvery: WhenQuantifier = (list, predicate) => ({ context: not(every(list, predicate)), fn: Boolean })\nwhenNotEvery.status = (items, status) => ({ context: not(every.status(items, status)), fn: Boolean })\n\nconst whenNotSome: WhenQuantifier = (list, predicate) => ({ context: not(some(list, predicate)), fn: Boolean })\nwhenNotSome.status = (items, status) => ({ context: not(some.status(items, status)), fn: Boolean })\n\nwhenNot.every = whenNotEvery\nwhenNot.some = whenNotSome\n\nconst when = {\n every: whenEvery,\n some: whenSome,\n not: whenNot,\n}\n\nexport { when }\n"],"mappings":";;AAAA,MAAM,eAAe;;;ACSrB,MAAM,aAAa,MAAkC,SACnD,CAAC,GAAG,KAAK,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,KAAK,UAAU,OACzC;CAAE,SAAS;CAAM,SAAS;AAAK,IAC/B;CAAE,SAAS,EAAE,MAAM,GAAG;CAAG,SAAS,CAAC,MAAM,GAAG,IAAI;AAAE;AAIxD,SAAS,MACP,GAAG,MACY;CACf,MAAM,CAAC,MAAM,GAAG,QAAQ;CACxB,MAAM,EAAE,SAAS,YAAY,UAAU,MAAM,IAAqB;CAElE,MAAM,UAAU,QAAQ,KAAK,WAC3B,GAAG,KAAK,MAAM,IACV;EACE,OAAO,QAAQ,WAAW,OAAO,MAAM;EACvC,QAAQ,MAAM;GACZ,QAAQ,SAAS,OAAO,MAAM;GAC9B,QAAQ,SAAS,OAAO,MAAM;GAC9B,OAAO,SAAS,OAAO,KAAK;EAC9B,CAAC;CACH,IACA,GAAG,IAAI,MAAM,IACX;EAAE,OAAO,QAAQ,UAAU,OAAO,MAAM;EAAG,QAAQ,SAAS,OAAO,KAAK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AU,OAAO,YAAY;CAAE,SAAS,KAAK,OAAO,OAAO,MAAM;CAAG,IAAI;AAAQ;AAQzF,MAAM,WAAoB,UAAU;CAAE,SAAS,IAAI,IAAI;CAAG,IAAI;AAAQ;AAEtE,MAAM,gBAAgC,MAAM,eAAe;CAAE,SAAS,IAAI,MAAM,MAAM,SAAS,CAAC;CAAG,IAAI;AAAQ;AAC/G,aAAa,UAAU,OAAO,YAAY;CAAE,SAAS,IAAI,MAAM,OAAO,OAAO,MAAM,CAAC;CAAG,IAAI;AAAQ;AAEnG,MAAM,eAA+B,MAAM,eAAe;CAAE,SAAS,IAAI,KAAK,MAAM,SAAS,CAAC;CAAG,IAAI;AAAQ;AAC7G,YAAY,UAAU,OAAO,YAAY;CAAE,SAAS,IAAI,KAAK,OAAO,OAAO,MAAM,CAAC;CAAG,IAAI;AAAQ;AAEjG,QAAQ,QAAQ;AAChB,QAAQ,OAAO;AAEf,MAAM,OAAO;CACX,OAAO;CACP,MAAM;CACN,KAAK;AACP"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@app-compose/coda",
3
+ "version": "3.0.0-beta.7",
4
+ "private": false,
5
+ "description": "Helper utilities for @app-compose/core — reusable building blocks for tasks, wires, and context.",
6
+ "keywords": [
7
+ "app-compose",
8
+ "grlt",
9
+ "grlt-hub",
10
+ "helpers",
11
+ "tasks",
12
+ "typescript",
13
+ "utilities",
14
+ "utils",
15
+ "wire"
16
+ ],
17
+ "homepage": "https://app-compose.dev/coda",
18
+ "license": "MIT",
19
+ "contributors": [
20
+ {
21
+ "name": "Mikhail Kireev",
22
+ "url": "https://github.com/kireevmp"
23
+ },
24
+ {
25
+ "name": "Viktor Pasynok",
26
+ "url": "https://github.com/binjospookie"
27
+ }
28
+ ],
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/grlt-hub/app-compose.git"
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "type": "module",
37
+ "main": "./dist/index.cjs",
38
+ "module": "./dist/index.js",
39
+ "types": "./dist/index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "import": {
43
+ "types": "./dist/index.d.ts",
44
+ "default": "./dist/index.js"
45
+ },
46
+ "require": {
47
+ "types": "./dist/index.d.cts",
48
+ "default": "./dist/index.cjs"
49
+ }
50
+ },
51
+ "./package.json": "./package.json"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc --noEmit -p tsconfig.json && tsdown",
58
+ "dev": "tsdown --watch",
59
+ "prepack": "pnpm build",
60
+ "bench": "vitest bench",
61
+ "test": "vitest run",
62
+ "lint": "knip && oxlint ./src"
63
+ },
64
+ "devDependencies": {
65
+ "@app-compose/core": "workspace:*"
66
+ },
67
+ "peerDependencies": {
68
+ "@app-compose/core": "^3.0.0"
69
+ },
70
+ "packageManager": "pnpm@11.5.3+sha512.7ac1c919341c213a34dc0d02afb7143c5c26ac26ee8c4782deea821b8ac64d2134a081fd8941dae6e29bbb48f58dfc2b7fbceeccc07cb2f09d219d342a4969ed"
71
+ }