@enlitt/protocol 0.1.0 → 0.1.1

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,73 @@
1
+ /**
2
+ * The outreach visit wire contract: `POST /v1/outreach/visits` and
3
+ * `GET /v1/outreach/visits` (`specs/PROTOCOLS.md` "Outreach visits").
4
+ *
5
+ * Outreach emails link to `/developers?ref=<tracking_id>`. The developer page
6
+ * reports that it was opened with such a link, and the outreach team reads the
7
+ * reports back with a private token. Neither route is part of the SDK or the
8
+ * dashboard API, so both are deliberately absent from `contract.json`'s public
9
+ * route list; only the developer page, the backend, and the outreach tools use
10
+ * these validators.
11
+ *
12
+ * Every validator is strict: an unknown member or query parameter is refused.
13
+ */
14
+ import type { ResponseValidationResult } from "./responses.cjs";
15
+ type Result<T> = ResponseValidationResult<T>;
16
+ /** A tracking ID and a visitor key: 32 lowercase hexadecimal characters. */
17
+ export declare const OUTREACH_TRACKING_ID_PATTERN: RegExp;
18
+ /** The largest `POST /v1/outreach/visits` body the backend reads. */
19
+ export declare const OUTREACH_VISIT_REQUEST_MAX_BYTES = 1024;
20
+ export declare const OUTREACH_VISIT_EVENTS: readonly ["view", "engaged"];
21
+ export type OutreachVisitEvent = (typeof OUTREACH_VISIT_EVENTS)[number];
22
+ /** Reasons a visit may come from a scanner or another program, in output order. */
23
+ export declare const OUTREACH_AUTOMATED_SIGNALS: readonly ["user_agent", "webdriver", "hosting_network"];
24
+ export type OutreachAutomatedSignal = (typeof OUTREACH_AUTOMATED_SIGNALS)[number];
25
+ export declare const OUTREACH_VISIT_LIST_DEFAULT_LIMIT = 200;
26
+ export declare const OUTREACH_VISIT_LIST_MAX_LIMIT = 500;
27
+ /** The body the developer page sends for one visit event. */
28
+ export interface OutreachVisitRequest {
29
+ readonly tracking_id: string;
30
+ readonly event: OutreachVisitEvent;
31
+ readonly visitor_key: string;
32
+ readonly webdriver: boolean;
33
+ }
34
+ /**
35
+ * A validated list query: either every row of one tracking ID, or every row
36
+ * created at or after `since`, paged by an opaque cursor.
37
+ */
38
+ export type OutreachVisitListQuery = {
39
+ readonly kind: "tracking_id";
40
+ readonly tracking_id: string;
41
+ } | {
42
+ readonly kind: "since";
43
+ readonly since: string;
44
+ readonly cursor: string | null;
45
+ readonly limit: number;
46
+ };
47
+ export interface OutreachVisit {
48
+ readonly id: string;
49
+ readonly tracking_id: string;
50
+ readonly event: OutreachVisitEvent;
51
+ readonly visitor_key: string;
52
+ readonly visited_at: string;
53
+ readonly user_agent: string | null;
54
+ readonly webdriver: boolean;
55
+ readonly country: string | null;
56
+ readonly asn: number | null;
57
+ readonly as_organization: string | null;
58
+ readonly automated_signals: readonly OutreachAutomatedSignal[];
59
+ }
60
+ export interface OutreachVisitList {
61
+ readonly visits: readonly OutreachVisit[];
62
+ readonly next_cursor: string | null;
63
+ }
64
+ /** Validates an already-parsed visit report body. */
65
+ export declare function validateOutreachVisitRequest(value: unknown): Result<OutreachVisitRequest>;
66
+ /**
67
+ * Validates the list query. The cursor stays opaque here; the backend decodes
68
+ * it and refuses one it did not issue.
69
+ */
70
+ export declare function validateOutreachVisitListQuery(params: URLSearchParams): Result<OutreachVisitListQuery>;
71
+ /** Validates a `200` list response body. */
72
+ export declare function validateOutreachVisitList(value: unknown): Result<OutreachVisitList>;
73
+ export {};
@@ -0,0 +1,74 @@
1
+ /**
2
+ * The outreach visit wire contract: `POST /v1/outreach/visits` and
3
+ * `GET /v1/outreach/visits` (`specs/PROTOCOLS.md` "Outreach visits").
4
+ *
5
+ * Outreach emails link to `/developers?ref=<tracking_id>`. The developer page
6
+ * reports that it was opened with such a link, and the outreach team reads the
7
+ * reports back with a private token. Neither route is part of the SDK or the
8
+ * dashboard API, so both are deliberately absent from `contract.json`'s public
9
+ * route list; only the developer page, the backend, and the outreach tools use
10
+ * these validators.
11
+ *
12
+ * Every validator is strict: an unknown member or query parameter is refused.
13
+ */
14
+ import type { ResponseValidationResult } from "./responses.js";
15
+ type Result<T> = ResponseValidationResult<T>;
16
+ /** A tracking ID and a visitor key: 32 lowercase hexadecimal characters. */
17
+ export declare const OUTREACH_TRACKING_ID_PATTERN: RegExp;
18
+ /** The largest `POST /v1/outreach/visits` body the backend reads. */
19
+ export declare const OUTREACH_VISIT_REQUEST_MAX_BYTES = 1024;
20
+ export declare const OUTREACH_VISIT_EVENTS: readonly ["view", "engaged"];
21
+ export type OutreachVisitEvent = (typeof OUTREACH_VISIT_EVENTS)[number];
22
+ /** Reasons a visit may come from a scanner or another program, in output order. */
23
+ export declare const OUTREACH_AUTOMATED_SIGNALS: readonly ["user_agent", "webdriver", "hosting_network"];
24
+ export type OutreachAutomatedSignal = (typeof OUTREACH_AUTOMATED_SIGNALS)[number];
25
+ export declare const OUTREACH_VISIT_LIST_DEFAULT_LIMIT = 200;
26
+ export declare const OUTREACH_VISIT_LIST_MAX_LIMIT = 500;
27
+ /** The body the developer page sends for one visit event. */
28
+ export interface OutreachVisitRequest {
29
+ readonly tracking_id: string;
30
+ readonly event: OutreachVisitEvent;
31
+ readonly visitor_key: string;
32
+ readonly webdriver: boolean;
33
+ }
34
+ /**
35
+ * A validated list query: either every row of one tracking ID, or every row
36
+ * created at or after `since`, paged by an opaque cursor.
37
+ */
38
+ export type OutreachVisitListQuery = {
39
+ readonly kind: "tracking_id";
40
+ readonly tracking_id: string;
41
+ } | {
42
+ readonly kind: "since";
43
+ readonly since: string;
44
+ readonly cursor: string | null;
45
+ readonly limit: number;
46
+ };
47
+ export interface OutreachVisit {
48
+ readonly id: string;
49
+ readonly tracking_id: string;
50
+ readonly event: OutreachVisitEvent;
51
+ readonly visitor_key: string;
52
+ readonly visited_at: string;
53
+ readonly user_agent: string | null;
54
+ readonly webdriver: boolean;
55
+ readonly country: string | null;
56
+ readonly asn: number | null;
57
+ readonly as_organization: string | null;
58
+ readonly automated_signals: readonly OutreachAutomatedSignal[];
59
+ }
60
+ export interface OutreachVisitList {
61
+ readonly visits: readonly OutreachVisit[];
62
+ readonly next_cursor: string | null;
63
+ }
64
+ /** Validates an already-parsed visit report body. */
65
+ export declare function validateOutreachVisitRequest(value: unknown): Result<OutreachVisitRequest>;
66
+ /**
67
+ * Validates the list query. The cursor stays opaque here; the backend decodes
68
+ * it and refuses one it did not issue.
69
+ */
70
+ export declare function validateOutreachVisitListQuery(params: URLSearchParams): Result<OutreachVisitListQuery>;
71
+ /** Validates a `200` list response body. */
72
+ export declare function validateOutreachVisitList(value: unknown): Result<OutreachVisitList>;
73
+ export {};
74
+ //# sourceMappingURL=outreach.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outreach.d.ts","sourceRoot":"","sources":["../src/outreach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,KAAK,EAA4B,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAEzF,KAAK,MAAM,CAAC,CAAC,IAAI,wBAAwB,CAAC,CAAC,CAAC,CAAC;AAM7C,4EAA4E;AAC5E,eAAO,MAAM,4BAA4B,QAAmB,CAAC;AAE7D,qEAAqE;AACrE,eAAO,MAAM,gCAAgC,OAAO,CAAC;AAErD,eAAO,MAAM,qBAAqB,YAAI,MAAM,EAAE,SAAS,CAAU,CAAC;AAClE,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE,mFAAmF;AACnF,eAAO,MAAM,0BAA0B,YAAI,YAAY,EAAE,WAAW,EAAE,iBAAiB,CAAU,CAAC;AAClG,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAElF,eAAO,MAAM,iCAAiC,MAAM,CAAC;AACrD,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAEjD,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ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oBAAoB,CAAC,CAiBzF;AAQD;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAuCtG;AAqED,4CAA4C;AAC5C,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAgBnF"}
@@ -226,6 +226,15 @@
226
226
  "admissible_max_charge": "allowed",
227
227
  "limit_rule": "forbidden"
228
228
  },
229
+ "premium_not_enabled": {
230
+ "type": "permission_error",
231
+ "http_status": 403,
232
+ "retryable": false,
233
+ "retry_after": "forbidden",
234
+ "authorize_url": "forbidden",
235
+ "admissible_max_charge": "forbidden",
236
+ "limit_rule": "forbidden"
237
+ },
229
238
  "provider_error": {
230
239
  "type": "server_error",
231
240
  "http_status": 502,
package/package.json CHANGED
@@ -1,7 +1,16 @@
1
1
  {
2
2
  "name": "@enlitt/protocol",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Versioned runtime schemas and wire types for Enlitt",
5
+ "homepage": "https://enlitt.com/docs",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/enlitt/sdk.git",
9
+ "directory": "packages/protocol"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/enlitt/sdk/issues"
13
+ },
5
14
  "license": "MIT",
6
15
  "type": "module",
7
16
  "sideEffects": false,