@alistigo/artifact-config-list-format 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Mikael Labrut
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,18 @@
1
+ # @alistigo/artifact-config-list-format
2
+
3
+ JSON Schema and TypeScript types for the Alistigo list artifact config document.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ pnpm add @alistigo/artifact-config-list-format
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { validateListConfig, type ListArtifactConfig } from "@alistigo/artifact-config-list-format";
15
+
16
+ const config = validateListConfig({ readonly: true });
17
+ // => { readonly: true }
18
+ ```
@@ -0,0 +1,17 @@
1
+ export type { ListArtifactConfig } from "./types.js";
2
+ export { validateListConfig } from "./validate.js";
3
+ export declare const listConfigSchema: {
4
+ $schema: string;
5
+ $id: string;
6
+ title: string;
7
+ description: string;
8
+ type: string;
9
+ properties: {
10
+ readonly: {
11
+ type: string;
12
+ default: boolean;
13
+ };
14
+ };
15
+ additionalProperties: boolean;
16
+ };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAGnD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;CAAuB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export { validateListConfig } from "./validate.js";
2
+ import listConfigSchemaJson from "./schemas/list-config.json" with { type: "json" };
3
+ export const listConfigSchema = listConfigSchemaJson;
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,oBAAoB,MAAM,4BAA4B,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AACpF,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,69 @@
1
+ import { describe, expect, it } from "bun:test";
2
+ import { listConfigSchema, validateListConfig } from "./index.js";
3
+ describe("validateListConfig", () => {
4
+ describe("valid configs", () => {
5
+ it("accepts readonly=true", () => {
6
+ const result = validateListConfig({ readonly: true });
7
+ expect(result).toEqual({ readonly: true });
8
+ });
9
+ it("accepts readonly=false", () => {
10
+ const result = validateListConfig({ readonly: false });
11
+ expect(result).toEqual({ readonly: false });
12
+ });
13
+ it("defaults readonly to false when the field is missing", () => {
14
+ const result = validateListConfig({});
15
+ expect(result).toEqual({ readonly: false });
16
+ });
17
+ it("treats null as empty config (defaults apply)", () => {
18
+ const result = validateListConfig(null);
19
+ expect(result).toEqual({ readonly: false });
20
+ });
21
+ it("ignores extra fields and returns only list-relevant fields", () => {
22
+ const result = validateListConfig({ readonly: true, app: "alistigo", lang: "en" });
23
+ expect(result).toEqual({ readonly: true });
24
+ expect(result).not.toHaveProperty("app");
25
+ expect(result).not.toHaveProperty("lang");
26
+ });
27
+ it("ignores unknown extra fields with no readonly field", () => {
28
+ const result = validateListConfig({ app: "alistigo", someOtherField: 42 });
29
+ expect(result).toEqual({ readonly: false });
30
+ });
31
+ });
32
+ describe("invalid configs", () => {
33
+ it("throws if input is a string", () => {
34
+ expect(() => validateListConfig("true")).toThrow(TypeError);
35
+ });
36
+ it("throws if input is a number", () => {
37
+ expect(() => validateListConfig(42)).toThrow(TypeError);
38
+ });
39
+ it("throws if input is a boolean", () => {
40
+ expect(() => validateListConfig(true)).toThrow(TypeError);
41
+ });
42
+ it("throws if input is an array", () => {
43
+ expect(() => validateListConfig([])).toThrow(TypeError);
44
+ });
45
+ it("throws if readonly is a string instead of boolean", () => {
46
+ expect(() => validateListConfig({ readonly: "true" })).toThrow(TypeError);
47
+ });
48
+ it("throws if readonly is a number instead of boolean", () => {
49
+ expect(() => validateListConfig({ readonly: 1 })).toThrow(TypeError);
50
+ });
51
+ it("throws if readonly is null", () => {
52
+ expect(() => validateListConfig({ readonly: null })).toThrow(TypeError);
53
+ });
54
+ });
55
+ });
56
+ describe("listConfigSchema", () => {
57
+ it("exports the JSON Schema object", () => {
58
+ expect(listConfigSchema).toBeDefined();
59
+ expect(listConfigSchema.$schema).toBe("http://json-schema.org/draft-07/schema#");
60
+ expect(listConfigSchema.type).toBe("object");
61
+ });
62
+ it("schema has readonly property defined", () => {
63
+ expect(listConfigSchema.properties.readonly).toEqual({ type: "boolean", default: false });
64
+ });
65
+ it("schema forbids additional properties", () => {
66
+ expect(listConfigSchema.additionalProperties).toBe(false);
67
+ });
68
+ });
69
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAElE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,EAAE,CAAC,uBAAuB,EAAE,GAAG,EAAE;YAC/B,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;YACtD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;YAChC,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YACvD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sDAAsD,EAAE,GAAG,EAAE;YAC9D,MAAM,MAAM,GAAG,kBAAkB,CAAC,EAAE,CAAC,CAAC;YACtC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;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AAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,yCAAyC,CAAC,CAAC;QACjF,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/C,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,gBAAgB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@alistigo/artifact-config-list-format",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "private": false,
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ },
12
+ "./schemas/list-config.json": "./src/schemas/list-config.json"
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist",
18
+ "src/schemas"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "module": "./index.js"
24
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://alistigo.ai/schema/v1/artifact-config/list.json",
4
+ "title": "List Artifact Config",
5
+ "description": "Configuration document for the Alistigo list artifact.",
6
+ "type": "object",
7
+ "properties": {
8
+ "readonly": { "type": "boolean", "default": false }
9
+ },
10
+ "additionalProperties": false
11
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Configuration document for the Alistigo list artifact.
3
+ * Stored as the artifact's config document alongside the list document.
4
+ */
5
+ export interface ListArtifactConfig {
6
+ /** When true, the list cannot be modified by users. Defaults to false. */
7
+ readonly?: boolean;
8
+ }
9
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import type { ListArtifactConfig } from "./types.js";
2
+ /**
3
+ * Validate and extract list-specific config from an unknown value.
4
+ *
5
+ * Rules:
6
+ * - Input must be a non-array object (null is treated as empty config).
7
+ * - If `readonly` is present, it must be a boolean.
8
+ * - Extra fields are ignored — this function extracts only list-relevant fields,
9
+ * so it composes safely with the aggregate artifact-config validator that may
10
+ * pass in a config object containing fields like `app` or `lang`.
11
+ * - Returns a `ListArtifactConfig` with defaults applied (`readonly` defaults to false).
12
+ *
13
+ * @throws {TypeError} if the input is not an object, or if `readonly` is not a boolean.
14
+ */
15
+ export declare function validateListConfig(value: unknown): ListArtifactConfig;
16
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;GAYG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CAuBrE"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Validate and extract list-specific config from an unknown value.
3
+ *
4
+ * Rules:
5
+ * - Input must be a non-array object (null is treated as empty config).
6
+ * - If `readonly` is present, it must be a boolean.
7
+ * - Extra fields are ignored — this function extracts only list-relevant fields,
8
+ * so it composes safely with the aggregate artifact-config validator that may
9
+ * pass in a config object containing fields like `app` or `lang`.
10
+ * - Returns a `ListArtifactConfig` with defaults applied (`readonly` defaults to false).
11
+ *
12
+ * @throws {TypeError} if the input is not an object, or if `readonly` is not a boolean.
13
+ */
14
+ // fallow-ignore-next-line complexity
15
+ export function validateListConfig(value) {
16
+ if (value === null) {
17
+ return { readonly: false };
18
+ }
19
+ if (typeof value !== "object" || Array.isArray(value)) {
20
+ throw new TypeError(`List artifact config must be an object, got ${Array.isArray(value) ? "array" : typeof value}`);
21
+ }
22
+ const raw = value;
23
+ if ("readonly" in raw && raw.readonly !== undefined) {
24
+ if (typeof raw.readonly !== "boolean") {
25
+ throw new TypeError(`List artifact config: "readonly" must be a boolean, got ${typeof raw.readonly}`);
26
+ }
27
+ return { readonly: raw.readonly };
28
+ }
29
+ return { readonly: false };
30
+ }
31
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../src/validate.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,qCAAqC;AACrC,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACnB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,MAAM,IAAI,SAAS,CACjB,+CAA+C,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,KAAK,EAAE,CAC/F,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,KAAgC,CAAC;IAE7C,IAAI,UAAU,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;QACpD,IAAI,OAAO,GAAG,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;YACtC,MAAM,IAAI,SAAS,CACjB,2DAA2D,OAAO,GAAG,CAAC,QAAQ,EAAE,CACjF,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAmB,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;AAC7B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@alistigo/artifact-config-list-format",
3
+ "version": "0.1.0",
4
+ "license": "MIT",
5
+ "private": false,
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ },
12
+ "./schemas/list-config.json": "./src/schemas/list-config.json"
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist",
18
+ "src/schemas"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ }
23
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://alistigo.ai/schema/v1/artifact-config/list.json",
4
+ "title": "List Artifact Config",
5
+ "description": "Configuration document for the Alistigo list artifact.",
6
+ "type": "object",
7
+ "properties": {
8
+ "readonly": { "type": "boolean", "default": false }
9
+ },
10
+ "additionalProperties": false
11
+ }