@gate-forge/http-contract 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.
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Canonical HTTP contract facts (ADR 0004 D1).
3
+ *
4
+ * A contract fact is one discovered HTTP surface: either a backend server
5
+ * route or a frontend API-client call. Facts are evidence, never decisions:
6
+ * consumption relationships exist only after the deterministic join (D3)
7
+ * runs, and endpoint semantics are decided exclusively by the classifier
8
+ * over linked facts.
9
+ *
10
+ * The zod schemas here are the normative definitions; detectors serialize
11
+ * facts as GPP/3 resources of kind `http.contract` whose attributes carry
12
+ * this payload (open attribute record, so the wire shape stays compatible).
13
+ */
14
+ import { z } from 'zod';
15
+ /** Wire schema version for the fact payload. */
16
+ export declare const HTTP_CONTRACT_SCHEMA_VERSION = 1;
17
+ /** Schema version field with the same strictness rules as core. */
18
+ export declare const HttpContractSchemaVersionField: z.ZodLiteral<1>;
19
+ /** Concrete HTTP methods a fact may declare. `ANY` is exposure-only. */
20
+ export declare const HTTP_METHODS: readonly ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "ANY"];
21
+ export declare const HttpMethodSchema: z.ZodEnum<{
22
+ GET: "GET";
23
+ HEAD: "HEAD";
24
+ POST: "POST";
25
+ PUT: "PUT";
26
+ PATCH: "PATCH";
27
+ DELETE: "DELETE";
28
+ OPTIONS: "OPTIONS";
29
+ ANY: "ANY";
30
+ }>;
31
+ export type HttpMethod = (typeof HTTP_METHODS)[number];
32
+ /** Which side of the join the fact came from. */
33
+ export declare const HttpContractRoles: readonly ["server-route", "frontend-call"];
34
+ export declare const HttpContractRoleSchema: z.ZodEnum<{
35
+ "server-route": "server-route";
36
+ "frontend-call": "frontend-call";
37
+ }>;
38
+ export type HttpContractRole = (typeof HttpContractRoles)[number];
39
+ /** Source location, identical in shape to the core Location schema. */
40
+ export declare const HttpLocationSchema: z.ZodObject<{
41
+ file: z.ZodString;
42
+ line: z.ZodNumber;
43
+ col: z.ZodNumber;
44
+ }, z.core.$strict>;
45
+ export type HttpLocation = z.infer<typeof HttpLocationSchema>;
46
+ /**
47
+ * One discovered HTTP surface. Strict: unknown fields are rejected so a
48
+ * detector cannot smuggle unversioned payloads through the join.
49
+ */
50
+ export declare const HttpContractFactSchema: z.ZodObject<{
51
+ schemaVersion: z.ZodLiteral<1>;
52
+ role: z.ZodEnum<{
53
+ "server-route": "server-route";
54
+ "frontend-call": "frontend-call";
55
+ }>;
56
+ method: z.ZodEnum<{
57
+ GET: "GET";
58
+ HEAD: "HEAD";
59
+ POST: "POST";
60
+ PUT: "PUT";
61
+ PATCH: "PATCH";
62
+ DELETE: "DELETE";
63
+ OPTIONS: "OPTIONS";
64
+ ANY: "ANY";
65
+ }>;
66
+ normalizedPath: z.ZodString;
67
+ rawPath: z.ZodString;
68
+ framework: z.ZodString;
69
+ handlerSymbol: z.ZodOptional<z.ZodString>;
70
+ requestSchemaSymbols: z.ZodOptional<z.ZodArray<z.ZodString>>;
71
+ responseSchemaSymbols: z.ZodOptional<z.ZodArray<z.ZodString>>;
72
+ callsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
73
+ source: z.ZodObject<{
74
+ file: z.ZodString;
75
+ line: z.ZodNumber;
76
+ col: z.ZodNumber;
77
+ }, z.core.$strict>;
78
+ }, z.core.$strict>;
79
+ export type HttpContractFact = z.infer<typeof HttpContractFactSchema>;
80
+ /** Resource kind used to carry facts through GPP/3 as evidence-only resources. */
81
+ export declare const HTTP_CONTRACT_KIND = "http.contract";
82
+ /** Resource kind emitted by the endpoint compiler for joined endpoints. */
83
+ export declare const HTTP_ENDPOINT_KIND = "http.endpoint";
84
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gDAAgD;AAChD,eAAO,MAAM,4BAA4B,IAAI,CAAC;AAE9C,mEAAmE;AACnE,eAAO,MAAM,8BAA8B,iBAEzC,CAAC;AAEH,wEAAwE;AACxE,eAAO,MAAM,YAAY,8EASf,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;EAAuB,CAAC;AACrD,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvD,iDAAiD;AACjD,eAAO,MAAM,iBAAiB,4CAA6C,CAAC;AAC5E,eAAO,MAAM,sBAAsB;;;EAA4B,CAAC;AAChE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAElE,uEAAuE;AACvE,eAAO,MAAM,kBAAkB;;;;kBAMpB,CAAC;AACZ,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAsBxB,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,kFAAkF;AAClF,eAAO,MAAM,kBAAkB,kBAAkB,CAAC;AAElD,2EAA2E;AAC3E,eAAO,MAAM,kBAAkB,kBAAkB,CAAC"}
package/dist/schema.js ADDED
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Canonical HTTP contract facts (ADR 0004 D1).
3
+ *
4
+ * A contract fact is one discovered HTTP surface: either a backend server
5
+ * route or a frontend API-client call. Facts are evidence, never decisions:
6
+ * consumption relationships exist only after the deterministic join (D3)
7
+ * runs, and endpoint semantics are decided exclusively by the classifier
8
+ * over linked facts.
9
+ *
10
+ * The zod schemas here are the normative definitions; detectors serialize
11
+ * facts as GPP/3 resources of kind `http.contract` whose attributes carry
12
+ * this payload (open attribute record, so the wire shape stays compatible).
13
+ */
14
+ import { z } from 'zod';
15
+ /** Wire schema version for the fact payload. */
16
+ export const HTTP_CONTRACT_SCHEMA_VERSION = 1;
17
+ /** Schema version field with the same strictness rules as core. */
18
+ export const HttpContractSchemaVersionField = z.literal(1, {
19
+ error: 'http contract schemaVersion must be exactly 1',
20
+ });
21
+ /** Concrete HTTP methods a fact may declare. `ANY` is exposure-only. */
22
+ export const HTTP_METHODS = [
23
+ 'GET',
24
+ 'HEAD',
25
+ 'POST',
26
+ 'PUT',
27
+ 'PATCH',
28
+ 'DELETE',
29
+ 'OPTIONS',
30
+ 'ANY',
31
+ ];
32
+ export const HttpMethodSchema = z.enum(HTTP_METHODS);
33
+ /** Which side of the join the fact came from. */
34
+ export const HttpContractRoles = ['server-route', 'frontend-call'];
35
+ export const HttpContractRoleSchema = z.enum(HttpContractRoles);
36
+ /** Source location, identical in shape to the core Location schema. */
37
+ export const HttpLocationSchema = z
38
+ .object({
39
+ file: z.string().min(1),
40
+ line: z.number().int().min(1),
41
+ col: z.number().int().min(0),
42
+ })
43
+ .strict();
44
+ /**
45
+ * One discovered HTTP surface. Strict: unknown fields are rejected so a
46
+ * detector cannot smuggle unversioned payloads through the join.
47
+ */
48
+ export const HttpContractFactSchema = z
49
+ .object({
50
+ schemaVersion: HttpContractSchemaVersionField,
51
+ role: HttpContractRoleSchema,
52
+ method: HttpMethodSchema,
53
+ /** Canonical positional path (ADR 0004 D2), e.g. `/api/v1/accounts/{}`. */
54
+ normalizedPath: z.string().min(1),
55
+ /** Exactly as written in source, before canonicalization. */
56
+ rawPath: z.string().min(1),
57
+ /** Producing framework/client id, e.g. `fastapi`, `fetch`, `axios`. */
58
+ framework: z.string().min(1),
59
+ /** Backend handler symbol (server-route facts only). */
60
+ handlerSymbol: z.string().min(1).optional(),
61
+ /** Request body/query/dependency schema symbols (server-route facts). */
62
+ requestSchemaSymbols: z.array(z.string().min(1)).min(1).optional(),
63
+ /** Response model symbols (server-route facts). */
64
+ responseSchemaSymbols: z.array(z.string().min(1)).min(1).optional(),
65
+ /** Frontend callsite identifiers (frontend-call facts only). */
66
+ callsites: z.array(z.string().min(1)).min(1).optional(),
67
+ /** Where the fact was found. */
68
+ source: HttpLocationSchema,
69
+ })
70
+ .strict();
71
+ /** Resource kind used to carry facts through GPP/3 as evidence-only resources. */
72
+ export const HTTP_CONTRACT_KIND = 'http.contract';
73
+ /** Resource kind emitted by the endpoint compiler for joined endpoints. */
74
+ export const HTTP_ENDPOINT_KIND = 'http.endpoint';
75
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,gDAAgD;AAChD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,CAAC;AAE9C,mEAAmE;AACnE,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE;IACzD,KAAK,EAAE,+CAA+C;CACvD,CAAC,CAAC;AAEH,wEAAwE;AACxE,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,KAAK;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,OAAO;IACP,QAAQ;IACR,SAAS;IACT,KAAK;CACG,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAGrD,iDAAiD;AACjD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,cAAc,EAAE,eAAe,CAAU,CAAC;AAC5E,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;AAGhE,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAA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,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACvD,gCAAgC;IAChC,MAAM,EAAE,kBAAkB;CAC3B,CAAC;KACD,MAAM,EAAE,CAAC;AAIZ,kFAAkF;AAClF,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD,2EAA2E;AAC3E,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Package version for `@gate-forge/http-contract`. */
2
+ export declare const HTTP_CONTRACT_VERSION = "0.1.0";
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,eAAO,MAAM,qBAAqB,UAAU,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Package version for `@gate-forge/http-contract`. */
2
+ export const HTTP_CONTRACT_VERSION = '0.1.0';
3
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@gate-forge/http-contract",
3
+ "version": "0.1.0",
4
+ "license": "Apache-2.0",
5
+ "description": "Framework-neutral canonical HTTP contract: HttpContractFact schema, typed block codes, path/method normalization, and the deterministic frontend-call <-> server-route join engine (ADR 0004 D1-D4).",
6
+ "type": "module",
7
+ "engines": {
8
+ "node": ">=20"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "import": "./dist/index.js",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "README.md",
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.build.json",
25
+ "typecheck": "tsc -p tsconfig.json --noEmit",
26
+ "test": "vitest run"
27
+ },
28
+ "dependencies": {
29
+ "zod": "^4.1.5"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/umiddey/gateforge.git",
37
+ "directory": "packages/http-contract"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/umiddey/gateforge/issues"
41
+ },
42
+ "homepage": "https://github.com/umiddey/gateforge#readme"
43
+ }