@app-compose/coda 3.0.0-beta.10

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,54 @@
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)
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
+ | [defaultTo](https://app-compose.dev/coda/default-to) | Uses a fallback value when a Spot resolves to null or undefined. |
28
+ | [every](https://app-compose.dev/coda/every) | All-of quantifier for Tasks, Tags, and Spots — by predicate or Task status. |
29
+ | [some](https://app-compose.dev/coda/some) | Any-of quantifier for Tasks, Tags, and Spots — by predicate or Task status. |
30
+ | [not](https://app-compose.dev/coda/not) | Inverts a Spot into its boolean opposite. |
31
+ | [optionalOr](https://app-compose.dev/coda/optional-or) | Uses a fallback value when the source is missing or its value is null or undefined. |
32
+ | [when](https://app-compose.dev/coda/when) | Wraps `every`, `some`, and `not` into `{ context, fn: Boolean }`. |
33
+
34
+ ## AI tools
35
+
36
+ The documentation index includes links to Coda helpers.
37
+
38
+ ### Cursor
39
+
40
+ 1. Open chat and type `@docs`
41
+ 2. Click **Add new doc**
42
+ 3. Paste the URL and confirm:
43
+
44
+ ```
45
+ https://app-compose.dev/llms.txt
46
+ ```
47
+
48
+ ### Claude / ChatGPT / Copilot
49
+
50
+ Paste this URL into the chat — most assistants accept URLs as context:
51
+
52
+ ```
53
+ https://app-compose.dev/llms.txt
54
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,120 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _app_compose_core = require("@app-compose/core");
3
+ // src/shared.ts
4
+ const LIBRARY_NAME = "[coda]";
5
+ // src/debug/index.ts
6
+ const normalize = (head, tail) => !_app_compose_core.is.task(head) && !_app_compose_core.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) => _app_compose_core.is.task(target) ? {
17
+ title: (0, _app_compose_core.literal)(`[Task]: ${target.name}`),
18
+ output: (0, _app_compose_core.shape)({
19
+ status: (0, _app_compose_core.optional)(target.status),
20
+ result: (0, _app_compose_core.optional)(target.result),
21
+ error: (0, _app_compose_core.optional)(target.error)
22
+ })
23
+ } : _app_compose_core.is.tag(target) ? {
24
+ title: (0, _app_compose_core.literal)(`[Tag]: ${target.name}`),
25
+ output: (0, _app_compose_core.optional)(target.value)
26
+ } : {
27
+ title: (0, _app_compose_core.literal)("[Spot]"),
28
+ output: (0, _app_compose_core.optional)(target)
29
+ });
30
+ const taskName = `${LIBRARY_NAME} debug ${options.name}`.trimEnd();
31
+ return (0, _app_compose_core.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
+ // src/defaultTo/index.ts
48
+ const defaultTo = (spot, fallback) => _app_compose_core.is.spot(fallback) ? (0, _app_compose_core.shape)({
49
+ spot,
50
+ fallback
51
+ }, (from) => from.spot ?? from.fallback) : (0, _app_compose_core.shape)(spot, (from) => from ?? fallback);
52
+ // src/createQuantifier/index.ts
53
+ const createQuantifier = (mode) => {
54
+ 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) ? {
55
+ result: item.result,
56
+ status: item.status,
57
+ error: (0, _app_compose_core.optional)(item.error)
58
+ } : item), (values) => values[mode](predicate));
59
+ 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));
60
+ return quantifier;
61
+ };
62
+ // src/every/index.ts
63
+ const every = createQuantifier("every");
64
+ // src/some/index.ts
65
+ const some = createQuantifier("some");
66
+ // src/not/index.ts
67
+ const not = (value) => (0, _app_compose_core.shape)(value, (x) => !x);
68
+ // src/optionalOr/index.ts
69
+ const optionalOr = (spot, fallback) => defaultTo((0, _app_compose_core.optional)(spot), fallback);
70
+ // src/when/index.ts
71
+ const whenEvery = (list, predicate) => ({
72
+ context: every(list, predicate),
73
+ fn: Boolean
74
+ });
75
+ whenEvery.status = (items, status) => ({
76
+ context: every.status(items, status),
77
+ fn: Boolean
78
+ });
79
+ const whenSome = (list, predicate) => ({
80
+ context: some(list, predicate),
81
+ fn: Boolean
82
+ });
83
+ whenSome.status = (items, status) => ({
84
+ context: some.status(items, status),
85
+ fn: Boolean
86
+ });
87
+ const whenNot = (spot) => ({
88
+ context: not(spot),
89
+ fn: Boolean
90
+ });
91
+ const whenNotEvery = (list, predicate) => ({
92
+ context: not(every(list, predicate)),
93
+ fn: Boolean
94
+ });
95
+ whenNotEvery.status = (items, status) => ({
96
+ context: not(every.status(items, status)),
97
+ fn: Boolean
98
+ });
99
+ const whenNotSome = (list, predicate) => ({
100
+ context: not(some(list, predicate)),
101
+ fn: Boolean
102
+ });
103
+ whenNotSome.status = (items, status) => ({
104
+ context: not(some.status(items, status)),
105
+ fn: Boolean
106
+ });
107
+ whenNot.every = whenNotEvery;
108
+ whenNot.some = whenNotSome;
109
+ const when = {
110
+ every: whenEvery,
111
+ some: whenSome,
112
+ not: whenNot
113
+ };
114
+ exports.debug = debug;
115
+ exports.defaultTo = defaultTo;
116
+ exports.every = every;
117
+ exports.not = not;
118
+ exports.optionalOr = optionalOr;
119
+ exports.some = some;
120
+ exports.when = when;
@@ -0,0 +1,40 @@
1
+ import { Spot, SpotValue, Tag, Task, TaskResult, TaskStatus } from "@app-compose/core";
2
+ type DebugOptions = {
3
+ name: Task<unknown>["name"];
4
+ };
5
+ type DebugTarget = Task<unknown> | Tag<unknown> | Spot<unknown>;
6
+ declare function debug(opts: DebugOptions, target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
7
+ declare function debug(target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
8
+ declare const defaultTo: <T, P>(spot: Spot<T>, fallback: P | Spot<P>) => Spot<NonNullable<T> | P>;
9
+ type TaskValue<T> = {
10
+ result: TaskResult<T>;
11
+ status: TaskStatus;
12
+ error: SpotValue<Task<T>["error"]>;
13
+ };
14
+ type ItemValue<T> = T extends Task<unknown> ? TaskValue<T> : T extends Tag<infer V> ? V : T extends Spot<infer V> ? V : never;
15
+ type Quantifier<R> = {
16
+ <const List extends readonly (Task<unknown> | Tag<unknown> | Spot<unknown>)[]>(list: List, predicate: (values: ItemValue<List[number]>) => boolean): R;
17
+ status: <const Items extends readonly (Task<unknown> | Spot<TaskStatus | undefined>)[]>(items: Items, status: TaskStatus) => R;
18
+ };
19
+ export declare const every: Quantifier<import("@app-compose/core").Spot<boolean>>;
20
+ export declare const some: Quantifier<import("@app-compose/core").Spot<boolean>>;
21
+ type Not = (value: Spot<unknown>) => Spot<boolean>;
22
+ declare const not: Not;
23
+ declare const optionalOr: <T, P>(spot: Spot<T>, fallback: P | Spot<P>) => Spot<NonNullable<T> | P>;
24
+ type Result = {
25
+ context: Spot<boolean>;
26
+ fn: typeof Boolean;
27
+ };
28
+ type WhenQuantifier = Quantifier<Result>;
29
+ type WhenNot = {
30
+ (spot: Spot<unknown>): Result;
31
+ every: WhenQuantifier;
32
+ some: WhenQuantifier;
33
+ };
34
+ declare const when: {
35
+ every: WhenQuantifier;
36
+ some: WhenQuantifier;
37
+ not: WhenNot;
38
+ };
39
+ export { debug, defaultTo, not, optionalOr, when };
40
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":["_$___createQuantifier0.Quantifier","_$___createQuantifier0.Quantifier"],"sources":["../src/debug/index.ts","../src/defaultTo/index.ts","../src/createQuantifier/index.ts","../src/every/index.ts","../src/some/index.ts","../src/not/index.ts","../src/optionalOr/index.ts","../src/when/index.ts"],"mappings":";KAGK;EACH,MAAM;;KAGH,cAAc,gBAAgB,eAAe;iBAOzC,MAAM,MAAM,cAAc,QAAQ,gBAAgB,SAAS,gBAAgB;iBAC3E,MAAM,QAAQ,gBAAgB,SAAS,gBAAgB;cCb1D,YAAa,GAAG,GAAC,MAAQ,KAAK,IAAE,UAAY,IAAI,KAAK,OAAK,KAAK,YAAY,KAAK;KCUjF,UAAU;EAAO,QAAQ,WAAW;EAAI,QAAQ;EAAY,OAAO,UAAU,KAAK;;KAElF,UAAU,KACb,UAAU,gBAAgB,UAAU,KAAK,UAAU,UAAU,KAAK,IAAI,UAAU,WAAW,KAAK;KAE7F,WAAW;SACP,uBAAuB,gBAAgB,eAAe,kBAC3D,MAAM,MACN,YAAY,QAAQ,UAAU,4BAC7B;EACH,eAAe,wBAAwB,gBAAgB,KAAK,4BAC1D,OAAO,OACP,QAAQ,eACL;;qBCvBM,OAAAA,uCAAK;qBCAL,MAAAC,uCAAI;KCAZ,OAAO,OAAO,kBAAkB;cAE/B,KAAK;cCDL,aAAc,GAAG,GAAC,MAAQ,KAAK,IAAE,UAAY,IAAI,KAAK,OAAK,KAAK,YAAY,KAAK;KCGlF;EAAW,SAAS;EAAe,WAAW;;KAE9C,iBAAiB,WAAW;KAQ5B;GACF,MAAM,gBAAgB;EACvB,OAAO;EACP,MAAM;;cAcF;EACJ,OAAK;EACL,MAAI;EACJ,KAAG"}
@@ -0,0 +1,40 @@
1
+ import { Spot, SpotValue, Tag, Task, TaskResult, TaskStatus } from "@app-compose/core";
2
+ type DebugOptions = {
3
+ name: Task<unknown>["name"];
4
+ };
5
+ type DebugTarget = Task<unknown> | Tag<unknown> | Spot<unknown>;
6
+ declare function debug(opts: DebugOptions, target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
7
+ declare function debug(target: DebugTarget, ...targets: DebugTarget[]): Task<unknown>;
8
+ declare const defaultTo: <T, P>(spot: Spot<T>, fallback: P | Spot<P>) => Spot<NonNullable<T> | P>;
9
+ type TaskValue<T> = {
10
+ result: TaskResult<T>;
11
+ status: TaskStatus;
12
+ error: SpotValue<Task<T>["error"]>;
13
+ };
14
+ type ItemValue<T> = T extends Task<unknown> ? TaskValue<T> : T extends Tag<infer V> ? V : T extends Spot<infer V> ? V : never;
15
+ type Quantifier<R> = {
16
+ <const List extends readonly (Task<unknown> | Tag<unknown> | Spot<unknown>)[]>(list: List, predicate: (values: ItemValue<List[number]>) => boolean): R;
17
+ status: <const Items extends readonly (Task<unknown> | Spot<TaskStatus | undefined>)[]>(items: Items, status: TaskStatus) => R;
18
+ };
19
+ export declare const every: Quantifier<import("@app-compose/core").Spot<boolean>>;
20
+ export declare const some: Quantifier<import("@app-compose/core").Spot<boolean>>;
21
+ type Not = (value: Spot<unknown>) => Spot<boolean>;
22
+ declare const not: Not;
23
+ declare const optionalOr: <T, P>(spot: Spot<T>, fallback: P | Spot<P>) => Spot<NonNullable<T> | P>;
24
+ type Result = {
25
+ context: Spot<boolean>;
26
+ fn: typeof Boolean;
27
+ };
28
+ type WhenQuantifier = Quantifier<Result>;
29
+ type WhenNot = {
30
+ (spot: Spot<unknown>): Result;
31
+ every: WhenQuantifier;
32
+ some: WhenQuantifier;
33
+ };
34
+ declare const when: {
35
+ every: WhenQuantifier;
36
+ some: WhenQuantifier;
37
+ not: WhenNot;
38
+ };
39
+ export { debug, defaultTo, not, optionalOr, when };
40
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["_$___createQuantifier0.Quantifier","_$___createQuantifier0.Quantifier"],"sources":["../src/debug/index.ts","../src/defaultTo/index.ts","../src/createQuantifier/index.ts","../src/every/index.ts","../src/some/index.ts","../src/not/index.ts","../src/optionalOr/index.ts","../src/when/index.ts"],"mappings":";KAGK;EACH,MAAM;;KAGH,cAAc,gBAAgB,eAAe;iBAOzC,MAAM,MAAM,cAAc,QAAQ,gBAAgB,SAAS,gBAAgB;iBAC3E,MAAM,QAAQ,gBAAgB,SAAS,gBAAgB;cCb1D,YAAa,GAAG,GAAC,MAAQ,KAAK,IAAE,UAAY,IAAI,KAAK,OAAK,KAAK,YAAY,KAAK;KCUjF,UAAU;EAAO,QAAQ,WAAW;EAAI,QAAQ;EAAY,OAAO,UAAU,KAAK;;KAElF,UAAU,KACb,UAAU,gBAAgB,UAAU,KAAK,UAAU,UAAU,KAAK,IAAI,UAAU,WAAW,KAAK;KAE7F,WAAW;SACP,uBAAuB,gBAAgB,eAAe,kBAC3D,MAAM,MACN,YAAY,QAAQ,UAAU,4BAC7B;EACH,eAAe,wBAAwB,gBAAgB,KAAK,4BAC1D,OAAO,OACP,QAAQ,eACL;;qBCvBM,OAAAA,uCAAK;qBCAL,MAAAC,uCAAI;KCAZ,OAAO,OAAO,kBAAkB;cAE/B,KAAK;cCDL,aAAc,GAAG,GAAC,MAAQ,KAAK,IAAE,UAAY,IAAI,KAAK,OAAK,KAAK,YAAY,KAAK;KCGlF;EAAW,SAAS;EAAe,WAAW;;KAE9C,iBAAiB,WAAW;KAQ5B;GACF,MAAM,gBAAgB;EACvB,OAAO;EACP,MAAM;;cAcF;EACJ,OAAK;EACL,MAAI;EACJ,KAAG"}
package/dist/index.js ADDED
@@ -0,0 +1,115 @@
1
+ import { createTask, is, literal, optional, shape } from "@app-compose/core";
2
+ // src/shared.ts
3
+ const LIBRARY_NAME = "[coda]";
4
+ // src/debug/index.ts
5
+ const normalize = (head, tail) => !is.task(head) && !is.tag(head) && "name" in head ? {
6
+ options: head,
7
+ targets: tail
8
+ } : {
9
+ options: { name: "" },
10
+ targets: [head, ...tail]
11
+ };
12
+ function debug(...args) {
13
+ const [head, ...tail] = args;
14
+ const { options, targets } = normalize(head, tail);
15
+ const context = targets.map((target) => is.task(target) ? {
16
+ title: literal(`[Task]: ${target.name}`),
17
+ output: shape({
18
+ status: optional(target.status),
19
+ result: optional(target.result),
20
+ error: optional(target.error)
21
+ })
22
+ } : is.tag(target) ? {
23
+ title: literal(`[Tag]: ${target.name}`),
24
+ output: optional(target.value)
25
+ } : {
26
+ title: literal("[Spot]"),
27
+ output: optional(target)
28
+ });
29
+ const taskName = `${LIBRARY_NAME} debug ${options.name}`.trimEnd();
30
+ return createTask({
31
+ name: taskName,
32
+ run: {
33
+ context,
34
+ fn: (list) => {
35
+ console.groupCollapsed(taskName);
36
+ for (const target of list) {
37
+ console.group(target.title);
38
+ console.info(target.output);
39
+ console.groupEnd();
40
+ }
41
+ console.groupEnd();
42
+ }
43
+ }
44
+ });
45
+ }
46
+ // src/defaultTo/index.ts
47
+ const defaultTo = (spot, fallback) => is.spot(fallback) ? shape({
48
+ spot,
49
+ fallback
50
+ }, (from) => from.spot ?? from.fallback) : shape(spot, (from) => from ?? fallback);
51
+ // src/createQuantifier/index.ts
52
+ const createQuantifier = (mode) => {
53
+ const quantifier = (list, predicate) => shape(list.map((item) => is.tag(item) ? item.value : is.task(item) ? {
54
+ result: item.result,
55
+ status: item.status,
56
+ error: optional(item.error)
57
+ } : item), (values) => values[mode](predicate));
58
+ quantifier.status = (items, status) => shape(items.map((item) => is.task(item) ? item.status : item), (statuses) => statuses[mode]((s) => s === status));
59
+ return quantifier;
60
+ };
61
+ // src/every/index.ts
62
+ const every = createQuantifier("every");
63
+ // src/some/index.ts
64
+ const some = createQuantifier("some");
65
+ // src/not/index.ts
66
+ const not = (value) => shape(value, (x) => !x);
67
+ // src/optionalOr/index.ts
68
+ const optionalOr = (spot, fallback) => defaultTo(optional(spot), fallback);
69
+ // 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
+ export { debug, defaultTo, every, not, optionalOr, 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/defaultTo/index.ts","../src/createQuantifier/index.ts","../src/every/index.ts","../src/some/index.ts","../src/not/index.ts","../src/optionalOr/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 { is, shape, type Spot } from \"@app-compose/core\"\n\nconst defaultTo = <T, P>(spot: Spot<T>, fallback: P | Spot<P>): Spot<NonNullable<T> | P> =>\n is.spot(fallback)\n ? shape({ spot, fallback }, (from) => from.spot ?? from.fallback)\n : shape(spot, (from) => from ?? fallback)\n\nexport { defaultTo }\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 }\n","import { optional, type Spot } from \"@app-compose/core\"\nimport { defaultTo } from \"../defaultTo\"\n\nconst optionalOr = <T, P>(spot: Spot<T>, fallback: P | Spot<P>): Spot<NonNullable<T> | P> =>\n defaultTo(optional(spot), fallback)\n\nexport { optionalOr }\n","import type { Spot } from \"@app-compose/core\"\nimport type { Quantifier } from \"../createQuantifier\"\nimport { every } from \"../every\"\nimport { 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: Spot<unknown>): 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":"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"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@app-compose/coda",
3
+ "version": "3.0.0-beta.10",
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
+ "devDependencies": {
57
+ "@app-compose/core": "3.0.0-beta.10"
58
+ },
59
+ "peerDependencies": {
60
+ "@app-compose/core": "^3.0.0-beta.10"
61
+ },
62
+ "scripts": {
63
+ "build": "pnpm typecheck && tsdown",
64
+ "typecheck": "tsgo --noEmit -p tsconfig.json",
65
+ "dev": "tsdown --watch",
66
+ "bench": "vitest bench",
67
+ "test": "vitest run",
68
+ "lint": "knip && oxlint ./src",
69
+ "lint:fix": "oxlint --fix ./src"
70
+ }
71
+ }