@webpieces/rules-sdk 0.0.0-stage → 0.4.846

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/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "@webpieces/rules-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.4.846",
4
+ "description": "Pure schema and rule pack value contracts.",
5
+ "type": "commonjs",
6
+ "main": "./src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js",
9
+ "./package.json": "./package.json"
10
+ },
11
+ "files": [
12
+ "src/**/*",
13
+ "README.md"
14
+ ],
15
+ "dependencies": {
16
+ "tslib": "2.8.1"
17
+ },
18
+ "author": "Dean Hiller",
19
+ "license": "Apache-2.0",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/deanhiller/webpieces-ts.git",
23
+ "directory": "packages/tooling/rules-sdk"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "types": "./src/index.d.ts"
6
29
  }
@@ -0,0 +1,10 @@
1
+ import { FieldDef } from './field-def';
2
+ export declare abstract class BaseRuleConfig {
3
+ mode?: string;
4
+ turnOffRuleUntilEpoch?: number;
5
+ turnOffRuleWhileOnBranch?: string | null;
6
+ }
7
+ export declare const BASE_RULE_SCHEMA: {
8
+ turnOffRuleUntilEpoch: FieldDef;
9
+ turnOffRuleWhileOnBranch: FieldDef;
10
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BASE_RULE_SCHEMA = exports.BaseRuleConfig = void 0;
4
+ const field_def_1 = require("./field-def");
5
+ class BaseRuleConfig {
6
+ // `mode` is declared here (loosely typed) so the shared AbstractRule base can read it for
7
+ // on/off. Each concrete *Config narrows it to its own union (e.g. `mode?: ModifiedCodeMode`),
8
+ // which is an assignable (covariant) override.
9
+ mode;
10
+ // TS-optional, but schema-REQUIRED (see BASE_RULE_SCHEMA) — same split as `mode`. Read directly by
11
+ // AbstractRule.shouldRun, RuleGate, and the code-rules validators.
12
+ turnOffRuleUntilEpoch;
13
+ turnOffRuleWhileOnBranch;
14
+ }
15
+ exports.BaseRuleConfig = BaseRuleConfig;
16
+ exports.BASE_RULE_SCHEMA = {
17
+ turnOffRuleUntilEpoch: new field_def_1.FieldDef('number'),
18
+ turnOffRuleWhileOnBranch: field_def_1.FieldDef.nullableString(),
19
+ };
20
+ //# sourceMappingURL=base-rule-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-rule-config.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-sdk/src/base-rule-config.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAEvC,MAAsB,cAAc;IAChC,0FAA0F;IAC1F,8FAA8F;IAC9F,+CAA+C;IAC/C,IAAI,CAAU;IACd,mGAAmG;IACnG,mEAAmE;IACnE,qBAAqB,CAAU;IAC/B,wBAAwB,CAAiB;CAC5C;AATD,wCASC;AAEY,QAAA,gBAAgB,GAAG;IAC5B,qBAAqB,EAAE,IAAI,oBAAQ,CAAC,QAAQ,CAAC;IAC7C,wBAAwB,EAAE,oBAAQ,CAAC,cAAc,EAAE;CACtD,CAAC","sourcesContent":["import { FieldDef } from './field-def';\n\nexport abstract class BaseRuleConfig {\n // `mode` is declared here (loosely typed) so the shared AbstractRule base can read it for\n // on/off. Each concrete *Config narrows it to its own union (e.g. `mode?: ModifiedCodeMode`),\n // which is an assignable (covariant) override.\n mode?: string;\n // TS-optional, but schema-REQUIRED (see BASE_RULE_SCHEMA) — same split as `mode`. Read directly by\n // AbstractRule.shouldRun, RuleGate, and the code-rules validators.\n turnOffRuleUntilEpoch?: number;\n turnOffRuleWhileOnBranch?: string | null;\n}\n\nexport const BASE_RULE_SCHEMA = {\n turnOffRuleUntilEpoch: new FieldDef('number'),\n turnOffRuleWhileOnBranch: FieldDef.nullableString(),\n};\n\n"]}
@@ -0,0 +1,24 @@
1
+ type FieldType = 'string' | 'number' | 'boolean' | 'string[]' | 'object[]';
2
+ export declare class FieldDef {
3
+ readonly type: FieldType;
4
+ readonly enumValues?: readonly string[] | undefined;
5
+ readonly optional: boolean;
6
+ readonly nullable: boolean;
7
+ readonly nonEmpty: boolean;
8
+ readonly elementSchema?: Readonly<Record<string, FieldDef>> | undefined;
9
+ constructor(type: FieldType, enumValues?: readonly string[] | undefined, optional?: boolean, nullable?: boolean, nonEmpty?: boolean, elementSchema?: Readonly<Record<string, FieldDef>> | undefined);
10
+ /** Marks a field as optional (omittable) in the config schema. */
11
+ static optional(type: FieldType, enumValues?: readonly string[]): FieldDef;
12
+ /** A REQUIRED string field that also accepts `null` (present-but-unset). */
13
+ static nullableString(): FieldDef;
14
+ /** A REQUIRED `string[]` that must hold at least one string. */
15
+ static nonEmptyStrings(): FieldDef;
16
+ /** A REQUIRED list of objects (possibly empty), each validated against `elementSchema`. */
17
+ static objects(elementSchema: Readonly<Record<string, FieldDef>>): FieldDef;
18
+ /** A REQUIRED, non-empty list of objects, each validated against `elementSchema`. */
19
+ static nonEmptyObjects(elementSchema: Readonly<Record<string, FieldDef>>): FieldDef;
20
+ }
21
+ export type SchemaShape<T> = {
22
+ [K in keyof Required<T>]: FieldDef;
23
+ };
24
+ export {};
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldDef = void 0;
4
+ class FieldDef {
5
+ type;
6
+ enumValues;
7
+ optional;
8
+ nullable;
9
+ nonEmpty;
10
+ elementSchema;
11
+ constructor(type, enumValues,
12
+ // When true, the field is omittable: the missing-rule snippet lists it
13
+ // as optional rather than as a required copy-paste field.
14
+ optional = false,
15
+ // When true, JSON `null` is an accepted value in addition to `type`. Used for a REQUIRED
16
+ // field whose "unset" state must still be visible in the config (e.g. turnOffRuleWhileOnBranch:
17
+ // null means "no branch / always on") — required so it is always present, nullable so it can be
18
+ // present-but-unset without inventing a sentinel string.
19
+ nullable = false,
20
+ // When true, an array field (`string[]` / `object[]`) must hold at least one element — for a list
21
+ // whose emptiness would mean "judge nothing" while reading as "configured".
22
+ nonEmpty = false,
23
+ // For `object[]` only: the schema EVERY element is validated against (unknown keys, missing
24
+ // required keys, types, non-emptiness), exactly like a rule entry's own fields.
25
+ elementSchema) {
26
+ this.type = type;
27
+ this.enumValues = enumValues;
28
+ this.optional = optional;
29
+ this.nullable = nullable;
30
+ this.nonEmpty = nonEmpty;
31
+ this.elementSchema = elementSchema;
32
+ }
33
+ /** Marks a field as optional (omittable) in the config schema. */
34
+ // webpieces-disable no-function-outside-class -- pure schema value factory, matching the sibling FieldDef factories; the SDK intentionally has no DI
35
+ static optional(type, enumValues) {
36
+ return new FieldDef(type, enumValues, true);
37
+ }
38
+ /** A REQUIRED string field that also accepts `null` (present-but-unset). */
39
+ // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional
40
+ static nullableString() {
41
+ return new FieldDef('string', undefined, false, true);
42
+ }
43
+ /** A REQUIRED `string[]` that must hold at least one string. */
44
+ // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional
45
+ static nonEmptyStrings() {
46
+ return new FieldDef('string[]', undefined, false, false, true);
47
+ }
48
+ /** A REQUIRED list of objects (possibly empty), each validated against `elementSchema`. */
49
+ // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional
50
+ static objects(elementSchema) {
51
+ return new FieldDef('object[]', undefined, false, false, false, elementSchema);
52
+ }
53
+ /** A REQUIRED, non-empty list of objects, each validated against `elementSchema`. */
54
+ // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional
55
+ static nonEmptyObjects(elementSchema) {
56
+ return new FieldDef('object[]', undefined, false, false, true, elementSchema);
57
+ }
58
+ }
59
+ exports.FieldDef = FieldDef;
60
+ //# sourceMappingURL=field-def.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-def.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-sdk/src/field-def.ts"],"names":[],"mappings":";;;AAIA,MAAa,QAAQ;IAEJ;IACA;IAGA;IAKA;IAGA;IAGA;IAhBb,YACa,IAAe,EACf,UAA8B;IACvC,uEAAuE;IACvE,0DAA0D;IACjD,WAAoB,KAAK;IAClC,yFAAyF;IACzF,gGAAgG;IAChG,gGAAgG;IAChG,yDAAyD;IAChD,WAAoB,KAAK;IAClC,kGAAkG;IAClG,4EAA4E;IACnE,WAAoB,KAAK;IAClC,4FAA4F;IAC5F,gFAAgF;IACvE,aAAkD;QAflD,SAAI,GAAJ,IAAI,CAAW;QACf,eAAU,GAAV,UAAU,CAAoB;QAG9B,aAAQ,GAAR,QAAQ,CAAiB;QAKzB,aAAQ,GAAR,QAAQ,CAAiB;QAGzB,aAAQ,GAAR,QAAQ,CAAiB;QAGzB,kBAAa,GAAb,aAAa,CAAqC;IAC5D,CAAC;IAEJ,kEAAkE;IAClE,qJAAqJ;IACrJ,MAAM,CAAC,QAAQ,CAAC,IAAe,EAAE,UAA8B;QAC3D,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,4EAA4E;IAC5E,mGAAmG;IACnG,MAAM,CAAC,cAAc;QACjB,OAAO,IAAI,QAAQ,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC1D,CAAC;IAED,gEAAgE;IAChE,mGAAmG;IACnG,MAAM,CAAC,eAAe;QAClB,OAAO,IAAI,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAED,2FAA2F;IAC3F,mGAAmG;IACnG,MAAM,CAAC,OAAO,CAAC,aAAiD;QAC5D,OAAO,IAAI,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACnF,CAAC;IAED,qFAAqF;IACrF,mGAAmG;IACnG,MAAM,CAAC,eAAe,CAAC,aAAiD;QACpE,OAAO,IAAI,QAAQ,CAAC,UAAU,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;IAClF,CAAC;CACJ;AAjDD,4BAiDC","sourcesContent":["// `object[]` is a list of JSON objects, each validated against the field's `elementSchema` (e.g.\n// required-type-suffix's `entries`: `[{ \"paths\": [...], \"suffixes\": [...] }]`).\ntype FieldType = 'string' | 'number' | 'boolean' | 'string[]' | 'object[]';\n\nexport class FieldDef {\n constructor(\n readonly type: FieldType,\n readonly enumValues?: readonly string[],\n // When true, the field is omittable: the missing-rule snippet lists it\n // as optional rather than as a required copy-paste field.\n readonly optional: boolean = false,\n // When true, JSON `null` is an accepted value in addition to `type`. Used for a REQUIRED\n // field whose \"unset\" state must still be visible in the config (e.g. turnOffRuleWhileOnBranch:\n // null means \"no branch / always on\") — required so it is always present, nullable so it can be\n // present-but-unset without inventing a sentinel string.\n readonly nullable: boolean = false,\n // When true, an array field (`string[]` / `object[]`) must hold at least one element — for a list\n // whose emptiness would mean \"judge nothing\" while reading as \"configured\".\n readonly nonEmpty: boolean = false,\n // For `object[]` only: the schema EVERY element is validated against (unknown keys, missing\n // required keys, types, non-emptiness), exactly like a rule entry's own fields.\n readonly elementSchema?: Readonly<Record<string, FieldDef>>,\n ) {}\n\n /** Marks a field as optional (omittable) in the config schema. */\n // webpieces-disable no-function-outside-class -- pure schema value factory, matching the sibling FieldDef factories; the SDK intentionally has no DI\n static optional(type: FieldType, enumValues?: readonly string[]): FieldDef {\n return new FieldDef(type, enumValues, true);\n }\n\n /** A REQUIRED string field that also accepts `null` (present-but-unset). */\n // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional\n static nullableString(): FieldDef {\n return new FieldDef('string', undefined, false, true);\n }\n\n /** A REQUIRED `string[]` that must hold at least one string. */\n // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional\n static nonEmptyStrings(): FieldDef {\n return new FieldDef('string[]', undefined, false, false, true);\n }\n\n /** A REQUIRED list of objects (possibly empty), each validated against `elementSchema`. */\n // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional\n static objects(elementSchema: Readonly<Record<string, FieldDef>>): FieldDef {\n return new FieldDef('object[]', undefined, false, false, false, elementSchema);\n }\n\n /** A REQUIRED, non-empty list of objects, each validated against `elementSchema`. */\n // webpieces-disable no-function-outside-class -- static factory, matches sibling FieldDef.optional\n static nonEmptyObjects(elementSchema: Readonly<Record<string, FieldDef>>): FieldDef {\n return new FieldDef('object[]', undefined, false, false, true, elementSchema);\n }\n}\n\n// Enforces that a static SCHEMA has exactly the same keys as the config class.\n// Add a field to the class → TS errors until SCHEMA is updated.\n// Add to SCHEMA without adding to class → TS errors (extra property).\nexport type SchemaShape<T> = { [K in keyof Required<T>]: FieldDef };\n"]}
package/src/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export { FieldDef } from './field-def';
2
+ export type { SchemaShape } from './field-def';
3
+ export { BaseRuleConfig, BASE_RULE_SCHEMA } from './base-rule-config';
4
+ export { RULE_PACK_API_VERSION, RULE_SCHEMA_API_VERSION, ConfigObject, OwnedRuleDefinition, RuleContribution, RulePackManifest, RulePackDeclaration } from './rule-pack';
5
+ export type { ExecutionKind, ConfigValue } from './rule-pack';
6
+ export { FILE_LIMIT_MODES, MODIFIED_CODE_MODES, ON_OFF_MODES } from './scope-modes';
7
+ export type { FileLimitMode, ModifiedCodeMode, OnOffMode } from './scope-modes';
8
+ export { RetiredConfigKey, SafeguardDefinition } from './rule-pack';
9
+ export type { RuleConfigSection } from './rule-pack';
package/src/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SafeguardDefinition = exports.RetiredConfigKey = exports.ON_OFF_MODES = exports.MODIFIED_CODE_MODES = exports.FILE_LIMIT_MODES = exports.RulePackDeclaration = exports.RulePackManifest = exports.RuleContribution = exports.OwnedRuleDefinition = exports.ConfigObject = exports.RULE_SCHEMA_API_VERSION = exports.RULE_PACK_API_VERSION = exports.BASE_RULE_SCHEMA = exports.BaseRuleConfig = exports.FieldDef = void 0;
4
+ var field_def_1 = require("./field-def");
5
+ Object.defineProperty(exports, "FieldDef", { enumerable: true, get: function () { return field_def_1.FieldDef; } });
6
+ var base_rule_config_1 = require("./base-rule-config");
7
+ Object.defineProperty(exports, "BaseRuleConfig", { enumerable: true, get: function () { return base_rule_config_1.BaseRuleConfig; } });
8
+ Object.defineProperty(exports, "BASE_RULE_SCHEMA", { enumerable: true, get: function () { return base_rule_config_1.BASE_RULE_SCHEMA; } });
9
+ var rule_pack_1 = require("./rule-pack");
10
+ Object.defineProperty(exports, "RULE_PACK_API_VERSION", { enumerable: true, get: function () { return rule_pack_1.RULE_PACK_API_VERSION; } });
11
+ Object.defineProperty(exports, "RULE_SCHEMA_API_VERSION", { enumerable: true, get: function () { return rule_pack_1.RULE_SCHEMA_API_VERSION; } });
12
+ Object.defineProperty(exports, "ConfigObject", { enumerable: true, get: function () { return rule_pack_1.ConfigObject; } });
13
+ Object.defineProperty(exports, "OwnedRuleDefinition", { enumerable: true, get: function () { return rule_pack_1.OwnedRuleDefinition; } });
14
+ Object.defineProperty(exports, "RuleContribution", { enumerable: true, get: function () { return rule_pack_1.RuleContribution; } });
15
+ Object.defineProperty(exports, "RulePackManifest", { enumerable: true, get: function () { return rule_pack_1.RulePackManifest; } });
16
+ Object.defineProperty(exports, "RulePackDeclaration", { enumerable: true, get: function () { return rule_pack_1.RulePackDeclaration; } });
17
+ var scope_modes_1 = require("./scope-modes");
18
+ Object.defineProperty(exports, "FILE_LIMIT_MODES", { enumerable: true, get: function () { return scope_modes_1.FILE_LIMIT_MODES; } });
19
+ Object.defineProperty(exports, "MODIFIED_CODE_MODES", { enumerable: true, get: function () { return scope_modes_1.MODIFIED_CODE_MODES; } });
20
+ Object.defineProperty(exports, "ON_OFF_MODES", { enumerable: true, get: function () { return scope_modes_1.ON_OFF_MODES; } });
21
+ var rule_pack_2 = require("./rule-pack");
22
+ Object.defineProperty(exports, "RetiredConfigKey", { enumerable: true, get: function () { return rule_pack_2.RetiredConfigKey; } });
23
+ Object.defineProperty(exports, "SafeguardDefinition", { enumerable: true, get: function () { return rule_pack_2.SafeguardDefinition; } });
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-sdk/src/index.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AAA9B,qGAAA,QAAQ,OAAA;AAEjB,uDAAsE;AAA7D,kHAAA,cAAc,OAAA;AAAE,oHAAA,gBAAgB,OAAA;AACzC,yCAAyK;AAAhK,kHAAA,qBAAqB,OAAA;AAAE,oHAAA,uBAAuB,OAAA;AAAE,yGAAA,YAAY,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAAE,6GAAA,gBAAgB,OAAA;AAAE,gHAAA,mBAAmB,OAAA;AAEnJ,6CAAoF;AAA3E,+GAAA,gBAAgB,OAAA;AAAE,kHAAA,mBAAmB,OAAA;AAAE,2GAAA,YAAY,OAAA;AAG5D,yCAAoE;AAA3D,6GAAA,gBAAgB,OAAA;AAAE,gHAAA,mBAAmB,OAAA","sourcesContent":["export { FieldDef } from './field-def';\nexport type { SchemaShape } from './field-def';\nexport { BaseRuleConfig, BASE_RULE_SCHEMA } from './base-rule-config';\nexport { RULE_PACK_API_VERSION, RULE_SCHEMA_API_VERSION, ConfigObject, OwnedRuleDefinition, RuleContribution, RulePackManifest, RulePackDeclaration } from './rule-pack';\nexport type { ExecutionKind, ConfigValue } from './rule-pack';\nexport { FILE_LIMIT_MODES, MODIFIED_CODE_MODES, ON_OFF_MODES } from './scope-modes';\nexport type { FileLimitMode, ModifiedCodeMode, OnOffMode } from './scope-modes';\n\nexport { RetiredConfigKey, SafeguardDefinition } from './rule-pack';\nexport type { RuleConfigSection } from './rule-pack';\n"]}
@@ -0,0 +1,59 @@
1
+ import { FieldDef } from './field-def';
2
+ /** Versioned independently from npm releases: incompatible contracts require an explicit bump. */
3
+ export declare const RULE_PACK_API_VERSION = 2;
4
+ export declare const RULE_SCHEMA_API_VERSION = 1;
5
+ export type ExecutionKind = 'build' | 'source-hook' | 'workflow-guard' | 'lint';
6
+ export type ConfigValue = string | number | boolean | null | ConfigValue[] | ConfigObject;
7
+ export declare class ConfigObject {
8
+ [key: string]: ConfigValue;
9
+ }
10
+ /** The single owner supplies the configuration schema, regardless of implementation count. */
11
+ export declare class OwnedRuleDefinition {
12
+ readonly id: string;
13
+ readonly schema: Readonly<Record<string, FieldDef>>;
14
+ readonly schemaApiVersion: number;
15
+ readonly optionalTuning: ConfigObject;
16
+ readonly recommendedSeed: ConfigObject;
17
+ readonly section: RuleConfigSection;
18
+ constructor(id: string, schema: Readonly<Record<string, FieldDef>>, schemaApiVersion: number, optionalTuning: ConfigObject, recommendedSeed: ConfigObject, section: RuleConfigSection);
19
+ }
20
+ /** Each pack may implement an owned rule or contribute an execution kind to another owner. */
21
+ export declare class RuleContribution {
22
+ readonly ruleId: string;
23
+ readonly ownerPack: string;
24
+ readonly executionKind: ExecutionKind;
25
+ constructor(ruleId: string, ownerPack: string, executionKind: ExecutionKind);
26
+ }
27
+ export declare class RulePackManifest {
28
+ readonly packageName: string;
29
+ readonly packageVersion: string;
30
+ readonly apiVersion: number;
31
+ readonly ownedRules: readonly OwnedRuleDefinition[];
32
+ readonly contributions: readonly RuleContribution[];
33
+ readonly migrations: readonly RetiredConfigKey[];
34
+ readonly safeguards: readonly SafeguardDefinition[];
35
+ constructor(packageName: string, packageVersion: string, apiVersion: number, ownedRules: readonly OwnedRuleDefinition[], contributions: readonly RuleContribution[], migrations: readonly RetiredConfigKey[], safeguards: readonly SafeguardDefinition[]);
36
+ }
37
+ /** Explicit module declarations let a client add packs without a central built-in package list. */
38
+ export declare class RulePackDeclaration {
39
+ readonly module: string;
40
+ constructor(module: string);
41
+ }
42
+ export type RuleConfigSection = 'rules' | 'hookGuards' | 'lint';
43
+ /** A fixed invariant has no config switch; experimental safeguards require a separate explicit opt-in. */
44
+ export declare class SafeguardDefinition {
45
+ readonly id: string;
46
+ readonly activation: 'fixed' | 'experimental';
47
+ readonly description: string;
48
+ constructor(id: string, activation: 'fixed' | 'experimental', description: string);
49
+ }
50
+ /** Owner-provided migration instructions are data; the framework rejects rather than aliases retired keys. */
51
+ export declare class RetiredConfigKey {
52
+ readonly scope: string;
53
+ readonly key: string;
54
+ readonly movedTo: string;
55
+ readonly instruction: string;
56
+ readonly label: string;
57
+ readonly prunable: boolean;
58
+ constructor(scope: string, key: string, movedTo: string, instruction: string, label: string, prunable: boolean);
59
+ }
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RetiredConfigKey = exports.SafeguardDefinition = exports.RulePackDeclaration = exports.RulePackManifest = exports.RuleContribution = exports.OwnedRuleDefinition = exports.ConfigObject = exports.RULE_SCHEMA_API_VERSION = exports.RULE_PACK_API_VERSION = void 0;
4
+ /** Versioned independently from npm releases: incompatible contracts require an explicit bump. */
5
+ exports.RULE_PACK_API_VERSION = 2;
6
+ exports.RULE_SCHEMA_API_VERSION = 1;
7
+ class ConfigObject {
8
+ }
9
+ exports.ConfigObject = ConfigObject;
10
+ /** The single owner supplies the configuration schema, regardless of implementation count. */
11
+ class OwnedRuleDefinition {
12
+ id;
13
+ schema;
14
+ schemaApiVersion;
15
+ optionalTuning;
16
+ recommendedSeed;
17
+ section;
18
+ // eslint-disable-next-line @typescript-eslint/max-params
19
+ constructor(id, schema, schemaApiVersion, optionalTuning, recommendedSeed, section) {
20
+ this.id = id;
21
+ this.schema = schema;
22
+ this.schemaApiVersion = schemaApiVersion;
23
+ this.optionalTuning = optionalTuning;
24
+ this.recommendedSeed = recommendedSeed;
25
+ this.section = section;
26
+ }
27
+ }
28
+ exports.OwnedRuleDefinition = OwnedRuleDefinition;
29
+ /** Each pack may implement an owned rule or contribute an execution kind to another owner. */
30
+ class RuleContribution {
31
+ ruleId;
32
+ ownerPack;
33
+ executionKind;
34
+ constructor(ruleId, ownerPack, executionKind) {
35
+ this.ruleId = ruleId;
36
+ this.ownerPack = ownerPack;
37
+ this.executionKind = executionKind;
38
+ }
39
+ }
40
+ exports.RuleContribution = RuleContribution;
41
+ class RulePackManifest {
42
+ packageName;
43
+ packageVersion;
44
+ apiVersion;
45
+ ownedRules;
46
+ contributions;
47
+ migrations;
48
+ safeguards;
49
+ // eslint-disable-next-line @typescript-eslint/max-params
50
+ constructor(packageName, packageVersion, apiVersion, ownedRules, contributions, migrations, safeguards) {
51
+ this.packageName = packageName;
52
+ this.packageVersion = packageVersion;
53
+ this.apiVersion = apiVersion;
54
+ this.ownedRules = ownedRules;
55
+ this.contributions = contributions;
56
+ this.migrations = migrations;
57
+ this.safeguards = safeguards;
58
+ }
59
+ }
60
+ exports.RulePackManifest = RulePackManifest;
61
+ /** Explicit module declarations let a client add packs without a central built-in package list. */
62
+ class RulePackDeclaration {
63
+ module;
64
+ constructor(module) {
65
+ this.module = module;
66
+ }
67
+ }
68
+ exports.RulePackDeclaration = RulePackDeclaration;
69
+ /** A fixed invariant has no config switch; experimental safeguards require a separate explicit opt-in. */
70
+ class SafeguardDefinition {
71
+ id;
72
+ activation;
73
+ description;
74
+ constructor(id, activation, description) {
75
+ this.id = id;
76
+ this.activation = activation;
77
+ this.description = description;
78
+ }
79
+ }
80
+ exports.SafeguardDefinition = SafeguardDefinition;
81
+ /** Owner-provided migration instructions are data; the framework rejects rather than aliases retired keys. */
82
+ class RetiredConfigKey {
83
+ scope;
84
+ key;
85
+ movedTo;
86
+ instruction;
87
+ label;
88
+ prunable;
89
+ // eslint-disable-next-line @typescript-eslint/max-params
90
+ constructor(scope, key, movedTo, instruction, label, prunable) {
91
+ this.scope = scope;
92
+ this.key = key;
93
+ this.movedTo = movedTo;
94
+ this.instruction = instruction;
95
+ this.label = label;
96
+ this.prunable = prunable;
97
+ }
98
+ }
99
+ exports.RetiredConfigKey = RetiredConfigKey;
100
+ //# sourceMappingURL=rule-pack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-pack.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-sdk/src/rule-pack.ts"],"names":[],"mappings":";;;AAEA,kGAAkG;AACrF,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAC1B,QAAA,uBAAuB,GAAG,CAAC,CAAC;AAGzC,MAAa,YAAY;CAExB;AAFD,oCAEC;AAED,8FAA8F;AAC9F,MAAa,mBAAmB;IAGf;IACA;IACA;IACA;IACA;IACA;IAPb,yDAAyD;IACzD,YACa,EAAU,EACV,MAA0C,EAC1C,gBAAwB,EACxB,cAA4B,EAC5B,eAA6B,EAC7B,OAA0B;QAL1B,OAAE,GAAF,EAAE,CAAQ;QACV,WAAM,GAAN,MAAM,CAAoC;QAC1C,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,mBAAc,GAAd,cAAc,CAAc;QAC5B,oBAAe,GAAf,eAAe,CAAc;QAC7B,YAAO,GAAP,OAAO,CAAmB;IACpC,CAAC;CACP;AAVD,kDAUC;AAED,8FAA8F;AAC9F,MAAa,gBAAgB;IAEZ;IACA;IACA;IAHb,YACa,MAAc,EACd,SAAiB,EACjB,aAA4B;QAF5B,WAAM,GAAN,MAAM,CAAQ;QACd,cAAS,GAAT,SAAS,CAAQ;QACjB,kBAAa,GAAb,aAAa,CAAe;IACtC,CAAC;CACP;AAND,4CAMC;AAED,MAAa,gBAAgB;IAGZ;IACA;IACA;IACA;IACA;IACA;IACA;IARb,yDAAyD;IACzD,YACa,WAAmB,EACnB,cAAsB,EACtB,UAAkB,EAClB,UAA0C,EAC1C,aAA0C,EAC1C,UAAuC,EACvC,UAA0C;QAN1C,gBAAW,GAAX,WAAW,CAAQ;QACnB,mBAAc,GAAd,cAAc,CAAQ;QACtB,eAAU,GAAV,UAAU,CAAQ;QAClB,eAAU,GAAV,UAAU,CAAgC;QAC1C,kBAAa,GAAb,aAAa,CAA6B;QAC1C,eAAU,GAAV,UAAU,CAA6B;QACvC,eAAU,GAAV,UAAU,CAAgC;IACpD,CAAC;CACP;AAXD,4CAWC;AAED,mGAAmG;AACnG,MAAa,mBAAmB;IACP;IAArB,YAAqB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;IAAG,CAAC;CAC1C;AAFD,kDAEC;AAID,0GAA0G;AAC1G,MAAa,mBAAmB;IACP;IAAqB;IAA+C;IAAzF,YAAqB,EAAU,EAAW,UAAoC,EAAW,WAAmB;QAAvF,OAAE,GAAF,EAAE,CAAQ;QAAW,eAAU,GAAV,UAAU,CAA0B;QAAW,gBAAW,GAAX,WAAW,CAAQ;IAAG,CAAC;CACnH;AAFD,kDAEC;AAED,8GAA8G;AAC9G,MAAa,gBAAgB;IAGZ;IAAwB;IAAsB;IAC9C;IAA8B;IAAwB;IAHnE,yDAAyD;IACzD,YACa,KAAa,EAAW,GAAW,EAAW,OAAe,EAC7D,WAAmB,EAAW,KAAa,EAAW,QAAiB;QADvE,UAAK,GAAL,KAAK,CAAQ;QAAW,QAAG,GAAH,GAAG,CAAQ;QAAW,YAAO,GAAP,OAAO,CAAQ;QAC7D,gBAAW,GAAX,WAAW,CAAQ;QAAW,UAAK,GAAL,KAAK,CAAQ;QAAW,aAAQ,GAAR,QAAQ,CAAS;IACjF,CAAC;CACP;AAND,4CAMC","sourcesContent":["import { FieldDef } from './field-def';\n\n/** Versioned independently from npm releases: incompatible contracts require an explicit bump. */\nexport const RULE_PACK_API_VERSION = 2;\nexport const RULE_SCHEMA_API_VERSION = 1;\nexport type ExecutionKind = 'build' | 'source-hook' | 'workflow-guard' | 'lint';\nexport type ConfigValue = string | number | boolean | null | ConfigValue[] | ConfigObject;\nexport class ConfigObject {\n [key: string]: ConfigValue;\n}\n\n/** The single owner supplies the configuration schema, regardless of implementation count. */\nexport class OwnedRuleDefinition {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly id: string,\n readonly schema: Readonly<Record<string, FieldDef>>,\n readonly schemaApiVersion: number,\n readonly optionalTuning: ConfigObject,\n readonly recommendedSeed: ConfigObject,\n readonly section: RuleConfigSection,\n ) {}\n}\n\n/** Each pack may implement an owned rule or contribute an execution kind to another owner. */\nexport class RuleContribution {\n constructor(\n readonly ruleId: string,\n readonly ownerPack: string,\n readonly executionKind: ExecutionKind,\n ) {}\n}\n\nexport class RulePackManifest {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly packageName: string,\n readonly packageVersion: string,\n readonly apiVersion: number,\n readonly ownedRules: readonly OwnedRuleDefinition[],\n readonly contributions: readonly RuleContribution[],\n readonly migrations: readonly RetiredConfigKey[],\n readonly safeguards: readonly SafeguardDefinition[],\n ) {}\n}\n\n/** Explicit module declarations let a client add packs without a central built-in package list. */\nexport class RulePackDeclaration {\n constructor(readonly module: string) {}\n}\n\nexport type RuleConfigSection = 'rules' | 'hookGuards' | 'lint';\n\n/** A fixed invariant has no config switch; experimental safeguards require a separate explicit opt-in. */\nexport class SafeguardDefinition {\n constructor(readonly id: string, readonly activation: 'fixed' | 'experimental', readonly description: string) {}\n}\n\n/** Owner-provided migration instructions are data; the framework rejects rather than aliases retired keys. */\nexport class RetiredConfigKey {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n readonly scope: string, readonly key: string, readonly movedTo: string,\n readonly instruction: string, readonly label: string, readonly prunable: boolean,\n ) {}\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /** Shared scope vocabulary for generic custom rules and independent rule contributions. */
2
+ export declare const FILE_LIMIT_MODES: readonly ["OFF", "NEW_AND_MODIFIED_FILES"];
3
+ export type FileLimitMode = typeof FILE_LIMIT_MODES[number];
4
+ export declare const MODIFIED_CODE_MODES: readonly ["OFF", "NEW_AND_MODIFIED_CODE", "NEW_AND_MODIFIED_FILES", "MODIFIED_PROJECTS", "RUN_EVERY_TIME"];
5
+ export type ModifiedCodeMode = typeof MODIFIED_CODE_MODES[number];
6
+ export declare const ON_OFF_MODES: readonly ["ON", "OFF"];
7
+ export type OnOffMode = typeof ON_OFF_MODES[number];
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ON_OFF_MODES = exports.MODIFIED_CODE_MODES = exports.FILE_LIMIT_MODES = void 0;
4
+ /** Shared scope vocabulary for generic custom rules and independent rule contributions. */
5
+ exports.FILE_LIMIT_MODES = ['OFF', 'NEW_AND_MODIFIED_FILES'];
6
+ // The two WHOLE-SCOPE modes (#1027) reuse the existing vocabulary rather than inventing names:
7
+ // MODIFIED_PROJECTS — every in-scope file of every project the diff touches (plus the changed files
8
+ // themselves, so it is never narrower than NEW_AND_MODIFIED_FILES).
9
+ // RUN_EVERY_TIME — every in-scope file in the repo, every run.
10
+ // Both judge WHOLE files, exactly like NEW_AND_MODIFIED_FILES — only the file SET differs. They exist so
11
+ // a rule adopted at NEW_AND_MODIFIED_CODE can be measured ("what is left?") or finished off without a
12
+ // hack, and they are what `wp-validate-code --rule=<name> --mode=<mode> --projects=a,b` accepts.
13
+ // Edit-time (ai-hooks) treats every non-OFF mode alike: it judges the content being written.
14
+ exports.MODIFIED_CODE_MODES = ['OFF', 'NEW_AND_MODIFIED_CODE', 'NEW_AND_MODIFIED_FILES', 'MODIFIED_PROJECTS', 'RUN_EVERY_TIME'];
15
+ exports.ON_OFF_MODES = ['ON', 'OFF'];
16
+ //# sourceMappingURL=scope-modes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scope-modes.js","sourceRoot":"","sources":["../../../../../packages/tooling/rules-sdk/src/scope-modes.ts"],"names":[],"mappings":";;;AAAA,2FAA2F;AAC9E,QAAA,gBAAgB,GAAG,CAAC,KAAK,EAAE,wBAAwB,CAAU,CAAC;AAI3E,+FAA+F;AAC/F,sGAAsG;AACtG,0FAA0F;AAC1F,oEAAoE;AACpE,yGAAyG;AACzG,sGAAsG;AACtG,iGAAiG;AACjG,6FAA6F;AAChF,QAAA,mBAAmB,GAAG,CAAC,KAAK,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,gBAAgB,CAAU,CAAC;AAIjI,QAAA,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,CAAU,CAAC","sourcesContent":["/** Shared scope vocabulary for generic custom rules and independent rule contributions. */\nexport const FILE_LIMIT_MODES = ['OFF', 'NEW_AND_MODIFIED_FILES'] as const;\n\nexport type FileLimitMode = typeof FILE_LIMIT_MODES[number];\n\n// The two WHOLE-SCOPE modes (#1027) reuse the existing vocabulary rather than inventing names:\n// MODIFIED_PROJECTS — every in-scope file of every project the diff touches (plus the changed files\n// themselves, so it is never narrower than NEW_AND_MODIFIED_FILES).\n// RUN_EVERY_TIME — every in-scope file in the repo, every run.\n// Both judge WHOLE files, exactly like NEW_AND_MODIFIED_FILES — only the file SET differs. They exist so\n// a rule adopted at NEW_AND_MODIFIED_CODE can be measured (\"what is left?\") or finished off without a\n// hack, and they are what `wp-validate-code --rule=<name> --mode=<mode> --projects=a,b` accepts.\n// Edit-time (ai-hooks) treats every non-OFF mode alike: it judges the content being written.\nexport const MODIFIED_CODE_MODES = ['OFF', 'NEW_AND_MODIFIED_CODE', 'NEW_AND_MODIFIED_FILES', 'MODIFIED_PROJECTS', 'RUN_EVERY_TIME'] as const;\n\nexport type ModifiedCodeMode = typeof MODIFIED_CODE_MODES[number];\n\nexport const ON_OFF_MODES = ['ON', 'OFF'] as const;\n\nexport type OnOffMode = typeof ON_OFF_MODES[number];\n"]}
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.