@tellescope/sdk 1.256.13 → 1.256.14
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/lib/cjs/tests/api_tests/organization_signup.test.d.ts +20 -0
- package/lib/cjs/tests/api_tests/organization_signup.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/organization_signup.test.js +272 -0
- package/lib/cjs/tests/api_tests/organization_signup.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.d.ts +30 -0
- package/lib/cjs/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.js +336 -0
- package/lib/cjs/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.d.ts +6 -0
- package/lib/cjs/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.js +354 -0
- package/lib/cjs/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.d.ts +46 -0
- package/lib/cjs/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.js +389 -0
- package/lib/cjs/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0192-automated-actions-process-gate.test.d.ts +43 -0
- package/lib/cjs/tests/api_tests/security/F-0192-automated-actions-process-gate.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0192-automated-actions-process-gate.test.js +324 -0
- package/lib/cjs/tests/api_tests/security/F-0192-automated-actions-process-gate.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.d.ts +43 -0
- package/lib/cjs/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.js +282 -0
- package/lib/cjs/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.js.map +1 -0
- package/lib/cjs/tests/api_tests/tickets_bulk_assign_from_queue.test.d.ts +5 -0
- package/lib/cjs/tests/api_tests/tickets_bulk_assign_from_queue.test.d.ts.map +1 -0
- package/lib/cjs/tests/api_tests/tickets_bulk_assign_from_queue.test.js +329 -0
- package/lib/cjs/tests/api_tests/tickets_bulk_assign_from_queue.test.js.map +1 -0
- package/lib/cjs/tests/setup_isolated.d.ts +68 -0
- package/lib/cjs/tests/setup_isolated.d.ts.map +1 -0
- package/lib/cjs/tests/setup_isolated.js +232 -0
- package/lib/cjs/tests/setup_isolated.js.map +1 -0
- package/lib/cjs/tests/tests.d.ts.map +1 -1
- package/lib/cjs/tests/tests.js +257 -209
- package/lib/cjs/tests/tests.js.map +1 -1
- package/lib/cjs/tests/unit_tests/do_not_send_address.test.d.ts +2 -0
- package/lib/cjs/tests/unit_tests/do_not_send_address.test.d.ts.map +1 -0
- package/lib/cjs/tests/unit_tests/do_not_send_address.test.js +89 -0
- package/lib/cjs/tests/unit_tests/do_not_send_address.test.js.map +1 -0
- package/lib/cjs/tests/unit_tests/openapi_spec_freshness.test.d.ts +17 -0
- package/lib/cjs/tests/unit_tests/openapi_spec_freshness.test.d.ts.map +1 -0
- package/lib/cjs/tests/unit_tests/openapi_spec_freshness.test.js +140 -0
- package/lib/cjs/tests/unit_tests/openapi_spec_freshness.test.js.map +1 -0
- package/lib/esm/enduser.d.ts +1 -0
- package/lib/esm/enduser.d.ts.map +1 -1
- package/lib/esm/sdk.d.ts +3 -2
- package/lib/esm/sdk.d.ts.map +1 -1
- package/lib/esm/session.d.ts +1 -0
- package/lib/esm/session.d.ts.map +1 -1
- package/lib/esm/tests/api_tests/organization_signup.test.d.ts +20 -0
- package/lib/esm/tests/api_tests/organization_signup.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/organization_signup.test.js +264 -0
- package/lib/esm/tests/api_tests/organization_signup.test.js.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.d.ts +30 -0
- package/lib/esm/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.js +332 -0
- package/lib/esm/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.js.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.d.ts +6 -0
- package/lib/esm/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.js +350 -0
- package/lib/esm/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.js.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.d.ts +46 -0
- package/lib/esm/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.js +382 -0
- package/lib/esm/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.js.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0192-automated-actions-process-gate.test.d.ts +43 -0
- package/lib/esm/tests/api_tests/security/F-0192-automated-actions-process-gate.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0192-automated-actions-process-gate.test.js +317 -0
- package/lib/esm/tests/api_tests/security/F-0192-automated-actions-process-gate.test.js.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.d.ts +43 -0
- package/lib/esm/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.js +277 -0
- package/lib/esm/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.js.map +1 -0
- package/lib/esm/tests/api_tests/tickets_bulk_assign_from_queue.test.d.ts +5 -0
- package/lib/esm/tests/api_tests/tickets_bulk_assign_from_queue.test.d.ts.map +1 -0
- package/lib/esm/tests/api_tests/tickets_bulk_assign_from_queue.test.js +324 -0
- package/lib/esm/tests/api_tests/tickets_bulk_assign_from_queue.test.js.map +1 -0
- package/lib/esm/tests/setup_isolated.d.ts +68 -0
- package/lib/esm/tests/setup_isolated.d.ts.map +1 -0
- package/lib/esm/tests/setup_isolated.js +221 -0
- package/lib/esm/tests/setup_isolated.js.map +1 -0
- package/lib/esm/tests/tests.d.ts.map +1 -1
- package/lib/esm/tests/tests.js +257 -209
- package/lib/esm/tests/tests.js.map +1 -1
- package/lib/esm/tests/unit_tests/do_not_send_address.test.d.ts +2 -0
- package/lib/esm/tests/unit_tests/do_not_send_address.test.d.ts.map +1 -0
- package/lib/esm/tests/unit_tests/do_not_send_address.test.js +85 -0
- package/lib/esm/tests/unit_tests/do_not_send_address.test.js.map +1 -0
- package/lib/esm/tests/unit_tests/openapi_spec_freshness.test.d.ts +17 -0
- package/lib/esm/tests/unit_tests/openapi_spec_freshness.test.d.ts.map +1 -0
- package/lib/esm/tests/unit_tests/openapi_spec_freshness.test.js +113 -0
- package/lib/esm/tests/unit_tests/openapi_spec_freshness.test.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/tests/api_tests/organization_signup.test.ts +240 -0
- package/src/tests/api_tests/security/F-0179-booking-info-idor-token-mint.test.ts +225 -0
- package/src/tests/api_tests/security/F-0185-startlinktoken-enduser-staff-escalation.test.ts +162 -0
- package/src/tests/api_tests/security/F-0191-schema-adminonly-enforcement.test.ts +288 -0
- package/src/tests/api_tests/security/F-0192-automated-actions-process-gate.test.ts +238 -0
- package/src/tests/api_tests/security/F-0196-add-to-journey-foreign-enduserid.test.ts +208 -0
- package/src/tests/api_tests/tickets_bulk_assign_from_queue.test.ts +279 -0
- package/src/tests/setup_isolated.ts +170 -0
- package/src/tests/tests.ts +25 -0
- package/src/tests/unit_tests/do_not_send_address.test.ts +60 -0
- package/src/tests/unit_tests/openapi_spec_freshness.test.ts +88 -0
- package/test_generated.pdf +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"do_not_send_address.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/unit_tests/do_not_send_address.test.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,8BAA8B,qBAyB1C,CAAA"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
require('source-map-support').install();
|
|
38
|
+
import { assert, log_header, } from "@tellescope/testing";
|
|
39
|
+
/**
|
|
40
|
+
* The email-suppression predicate from packages/private/api/api/modules/sqs.ts.
|
|
41
|
+
*
|
|
42
|
+
* Mirrored here rather than imported: the API is a private package the SDK does not depend on. The
|
|
43
|
+
* point of the test is to pin the CONTRACT — prefix AND domain both required — because the guard is
|
|
44
|
+
* otherwise unobservable from a test (a suppressed message simply never reaches SQS), and because
|
|
45
|
+
* loosening it in either direction would start suppressing real mail or start sending test mail.
|
|
46
|
+
*
|
|
47
|
+
* If this drifts from sqs.ts, that is the signal to look at why.
|
|
48
|
+
*/
|
|
49
|
+
var is_do_not_send_address = function (emailAddress) { return (!!emailAddress && emailAddress.endsWith('@tellescope.com') && emailAddress.startsWith('dontsend')); };
|
|
50
|
+
export var do_not_send_address_unit_tests = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
+
var cases, _i, cases_1, _a, input, expected, why;
|
|
52
|
+
return __generator(this, function (_b) {
|
|
53
|
+
log_header("Do-not-send address predicate");
|
|
54
|
+
cases = [
|
|
55
|
+
['dontsend@tellescope.com', true, 'exact prefix and domain'],
|
|
56
|
+
['dontsend-signup-ab12@tellescope.com', true, 'suffixed local part (what provisioning generates)'],
|
|
57
|
+
['dontsend3@tellescope.com', true, 'numbered variant already used by the suite'],
|
|
58
|
+
// near misses — both halves are load-bearing
|
|
59
|
+
['dontsend@example.com', false, 'right prefix, wrong domain: must NOT suppress'],
|
|
60
|
+
['realuser@tellescope.com', false, 'right domain, wrong prefix: must NOT suppress'],
|
|
61
|
+
['notdontsend@tellescope.com', false, 'prefix must be at the START, not anywhere'],
|
|
62
|
+
['dontsend@tellescope.com.evil.com', false, 'domain must be a suffix, not a substring'],
|
|
63
|
+
[undefined, false, 'undefined is not suppressed (and must not throw)'],
|
|
64
|
+
['', false, 'empty string is not suppressed'],
|
|
65
|
+
];
|
|
66
|
+
for (_i = 0, cases_1 = cases; _i < cases_1.length; _i++) {
|
|
67
|
+
_a = cases_1[_i], input = _a[0], expected = _a[1], why = _a[2];
|
|
68
|
+
assert(is_do_not_send_address(input) === expected, "".concat(JSON.stringify(input), " should be ").concat(expected ? 'suppressed' : 'sent', " \u2014 ").concat(why), "".concat(JSON.stringify(input), " -> ").concat(expected ? 'suppressed' : 'sent', " (").concat(why, ")"));
|
|
69
|
+
}
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
});
|
|
72
|
+
}); };
|
|
73
|
+
// Allow running this test file independently
|
|
74
|
+
if (require.main === module) {
|
|
75
|
+
do_not_send_address_unit_tests()
|
|
76
|
+
.then(function () {
|
|
77
|
+
console.log("✅ Do-not-send address predicate tests completed successfully");
|
|
78
|
+
process.exit(0);
|
|
79
|
+
})
|
|
80
|
+
.catch(function (error) {
|
|
81
|
+
console.error("❌ Do-not-send address predicate tests failed:", error);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=do_not_send_address.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"do_not_send_address.test.js","sourceRoot":"","sources":["../../../../src/tests/unit_tests/do_not_send_address.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAC;AAExC,OAAO,EACL,MAAM,EACN,UAAU,GACX,MAAM,qBAAqB,CAAA;AAE5B;;;;;;;;;GASG;AACH,IAAM,sBAAsB,GAAG,UAAC,YAAqB,IAAK,OAAA,CACxD,CAAC,CAAC,YAAY,IAAI,YAAY,CAAC,QAAQ,CAAC,iBAAiB,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAClG,EAFyD,CAEzD,CAAA;AAED,MAAM,CAAC,IAAM,8BAA8B,GAAG;;;QAC5C,UAAU,CAAC,+BAA+B,CAAC,CAAA;QAErC,KAAK,GAA4C;YACrD,CAAC,yBAAyB,EAAE,IAAI,EAAE,yBAAyB,CAAC;YAC5D,CAAC,qCAAqC,EAAE,IAAI,EAAE,mDAAmD,CAAC;YAClG,CAAC,0BAA0B,EAAE,IAAI,EAAE,4CAA4C,CAAC;YAEhF,6CAA6C;YAC7C,CAAC,sBAAsB,EAAE,KAAK,EAAE,+CAA+C,CAAC;YAChF,CAAC,yBAAyB,EAAE,KAAK,EAAE,+CAA+C,CAAC;YACnF,CAAC,4BAA4B,EAAE,KAAK,EAAE,2CAA2C,CAAC;YAClF,CAAC,kCAAkC,EAAE,KAAK,EAAE,0CAA0C,CAAC;YAEvF,CAAC,SAAS,EAAE,KAAK,EAAE,kDAAkD,CAAC;YACtE,CAAC,EAAE,EAAE,KAAK,EAAE,gCAAgC,CAAC;SAC9C,CAAA;QAED,WAA0C,EAAL,eAAK,EAAL,mBAAK,EAAL,IAAK,EAAE;YAAjC,gBAAsB,EAArB,KAAK,QAAA,EAAE,QAAQ,QAAA,EAAE,GAAG,QAAA;YAC9B,MAAM,CACJ,sBAAsB,CAAC,KAAK,CAAC,KAAK,QAAQ,EAC1C,UAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,wBAAc,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,qBAAM,GAAG,CAAE,EACjF,UAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,iBAAO,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,eAAK,GAAG,MAAG,CAC3E,CAAA;SACF;;;KACF,CAAA;AAED,6CAA6C;AAC7C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC3B,8BAA8B,EAAE;SAC7B,IAAI,CAAC;QACJ,OAAO,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAA;QAC3E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC;SACD,KAAK,CAAC,UAAC,KAAK;QACX,OAAO,CAAC,KAAK,CAAC,+CAA+C,EAAE,KAAK,CAAC,CAAA;QACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC,CAAC,CAAA;CACL"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guard: packages/public/schema/openapi.json must match what the generator currently produces.
|
|
3
|
+
*
|
|
4
|
+
* The spec is git-tracked AND published inside @tellescope/schema (no `files` field, and the
|
|
5
|
+
* .npmignore covers only set_vars.sh), but nothing in the build or CI regenerates it. It had
|
|
6
|
+
* therefore drifted several commits behind schema.ts — which mattered because `adminOnly` is
|
|
7
|
+
* rendered into the spec as an "**Admin only.**" description prefix, so the published docs were
|
|
8
|
+
* advertising gates that had changed. That drift is the doc half of F-0191; the runtime half was
|
|
9
|
+
* fixed by making getCustomEndpointFields fall back to the schema flag.
|
|
10
|
+
*
|
|
11
|
+
* The generator is byte-deterministic (date `getExample`s are pinned in validation.ts precisely so
|
|
12
|
+
* this comparison is possible), so an exact match is a fair assertion.
|
|
13
|
+
*
|
|
14
|
+
* If this fails: cd packages/public/schema && node lib/cjs/generate-openapi.js ./openapi.json
|
|
15
|
+
*/
|
|
16
|
+
export declare const openapi_spec_freshness_unit_tests: () => Promise<void>;
|
|
17
|
+
//# sourceMappingURL=openapi_spec_freshness.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi_spec_freshness.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/unit_tests/openapi_spec_freshness.test.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iCAAiC,qBA+C7C,CAAA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
require('source-map-support').install();
|
|
38
|
+
import * as fs from "fs";
|
|
39
|
+
import * as os from "os";
|
|
40
|
+
import * as path from "path";
|
|
41
|
+
import { execFileSync } from "child_process";
|
|
42
|
+
import { assert, log_header, } from "@tellescope/testing";
|
|
43
|
+
/**
|
|
44
|
+
* Guard: packages/public/schema/openapi.json must match what the generator currently produces.
|
|
45
|
+
*
|
|
46
|
+
* The spec is git-tracked AND published inside @tellescope/schema (no `files` field, and the
|
|
47
|
+
* .npmignore covers only set_vars.sh), but nothing in the build or CI regenerates it. It had
|
|
48
|
+
* therefore drifted several commits behind schema.ts — which mattered because `adminOnly` is
|
|
49
|
+
* rendered into the spec as an "**Admin only.**" description prefix, so the published docs were
|
|
50
|
+
* advertising gates that had changed. That drift is the doc half of F-0191; the runtime half was
|
|
51
|
+
* fixed by making getCustomEndpointFields fall back to the schema flag.
|
|
52
|
+
*
|
|
53
|
+
* The generator is byte-deterministic (date `getExample`s are pinned in validation.ts precisely so
|
|
54
|
+
* this comparison is possible), so an exact match is a fair assertion.
|
|
55
|
+
*
|
|
56
|
+
* If this fails: cd packages/public/schema && node lib/cjs/generate-openapi.js ./openapi.json
|
|
57
|
+
*/
|
|
58
|
+
export var openapi_spec_freshness_unit_tests = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
+
var schemaPkgJson, schemaRoot, generator, committed, tmp, regenerated, onDisk, a, b_1, firstDiff;
|
|
60
|
+
var _a, _b;
|
|
61
|
+
return __generator(this, function (_c) {
|
|
62
|
+
log_header("OpenAPI spec freshness");
|
|
63
|
+
schemaPkgJson = require.resolve('@tellescope/schema/package.json');
|
|
64
|
+
schemaRoot = path.dirname(schemaPkgJson);
|
|
65
|
+
generator = path.join(schemaRoot, 'lib', 'cjs', 'generate-openapi.js');
|
|
66
|
+
committed = path.join(schemaRoot, 'openapi.json');
|
|
67
|
+
// Don't fail the suite for a stale/absent build — that is a build problem, not spec drift.
|
|
68
|
+
if (!fs.existsSync(generator)) {
|
|
69
|
+
console.log(" SKIPPED: generator not built at ".concat(generator, " (run ./build_cjs.sh)"));
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
}
|
|
72
|
+
assert(fs.existsSync(committed), "openapi.json missing at ".concat(committed), 'openapi.json is present');
|
|
73
|
+
tmp = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'openapi-freshness-')), 'openapi.json');
|
|
74
|
+
try {
|
|
75
|
+
execFileSync('node', [generator, tmp], { stdio: 'pipe' });
|
|
76
|
+
regenerated = fs.readFileSync(tmp, 'utf8');
|
|
77
|
+
onDisk = fs.readFileSync(committed, 'utf8');
|
|
78
|
+
if (regenerated !== onDisk) {
|
|
79
|
+
a = regenerated.split('\n');
|
|
80
|
+
b_1 = onDisk.split('\n');
|
|
81
|
+
firstDiff = a.findIndex(function (line, i) { return line !== b_1[i]; });
|
|
82
|
+
console.log(" regenerated ".concat(a.length, " lines vs committed ").concat(b_1.length, " lines;")
|
|
83
|
+
+ " first difference at line ".concat(firstDiff + 1));
|
|
84
|
+
if (firstDiff >= 0) {
|
|
85
|
+
console.log(" committed: ".concat(((_a = b_1[firstDiff]) !== null && _a !== void 0 ? _a : '<missing>').trim().slice(0, 160)));
|
|
86
|
+
console.log(" regenerated: ".concat(((_b = a[firstDiff]) !== null && _b !== void 0 ? _b : '<missing>').trim().slice(0, 160)));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
assert(regenerated === onDisk, 'openapi.json is stale — regenerate it: '
|
|
90
|
+
+ 'cd packages/public/schema && node lib/cjs/generate-openapi.js ./openapi.json', 'openapi.json matches the generator output');
|
|
91
|
+
}
|
|
92
|
+
finally {
|
|
93
|
+
try {
|
|
94
|
+
fs.rmSync(path.dirname(tmp), { recursive: true, force: true });
|
|
95
|
+
}
|
|
96
|
+
catch (_d) { }
|
|
97
|
+
}
|
|
98
|
+
return [2 /*return*/];
|
|
99
|
+
});
|
|
100
|
+
}); };
|
|
101
|
+
// Allow running this test file independently
|
|
102
|
+
if (require.main === module) {
|
|
103
|
+
openapi_spec_freshness_unit_tests()
|
|
104
|
+
.then(function () {
|
|
105
|
+
console.log("✅ OpenAPI spec freshness test completed successfully");
|
|
106
|
+
process.exit(0);
|
|
107
|
+
})
|
|
108
|
+
.catch(function (error) {
|
|
109
|
+
console.error("❌ OpenAPI spec freshness test failed:", error);
|
|
110
|
+
process.exit(1);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=openapi_spec_freshness.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openapi_spec_freshness.test.js","sourceRoot":"","sources":["../../../../src/tests/unit_tests/openapi_spec_freshness.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAC;AAExC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,OAAO,EACL,MAAM,EACN,UAAU,GACX,MAAM,qBAAqB,CAAA;AAE5B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,IAAM,iCAAiC,GAAG;;;;QAC/C,UAAU,CAAC,wBAAwB,CAAC,CAAA;QAG9B,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,iCAAiC,CAAC,CAAA;QAClE,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QACxC,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,qBAAqB,CAAC,CAAA;QACtE,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;QAEvD,2FAA2F;QAC3F,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAC7B,OAAO,CAAC,GAA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