@koderlabs/tasks-sdk-types 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 +179 -0
- package/README.md +9 -0
- package/dist/index.cjs +131 -0
- package/dist/index.d.cts +149 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.js +91 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
PROPRIETARY SOFTWARE LICENSE — ALL RIGHTS RESERVED
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KoderLabs. All rights reserved.
|
|
4
|
+
Author: Jawaid Gadiwala <jawaidgadiwala@gmail.com>
|
|
5
|
+
|
|
6
|
+
================================================================================
|
|
7
|
+
1. NO LICENSE GRANTED BY DEFAULT
|
|
8
|
+
================================================================================
|
|
9
|
+
|
|
10
|
+
This software, including all source code, object code, documentation,
|
|
11
|
+
configuration files, build artifacts, test fixtures, and any associated
|
|
12
|
+
materials (collectively, the "Software"), is the proprietary and confidential
|
|
13
|
+
property of KoderLabs.
|
|
14
|
+
|
|
15
|
+
NO license, right, title, interest, or permission of any kind — express,
|
|
16
|
+
implied, statutory, by estoppel, by exhaustion, by patent exhaustion, or by
|
|
17
|
+
any other legal theory — is granted to any person or entity by:
|
|
18
|
+
|
|
19
|
+
(a) viewing the Software on any registry, repository, mirror, CDN,
|
|
20
|
+
cache, or other distribution channel (including but not limited to
|
|
21
|
+
npmjs.com, GitHub, GitLab, or any private registry);
|
|
22
|
+
(b) downloading, cloning, or otherwise obtaining a copy of the Software;
|
|
23
|
+
(c) the act of the Software being technically accessible due to a registry
|
|
24
|
+
requirement, mirror, or third-party distribution;
|
|
25
|
+
(d) any prior course of dealing, custom, or industry practice.
|
|
26
|
+
|
|
27
|
+
The ability to access the Software does NOT imply any permission to use it.
|
|
28
|
+
A separate, signed, written license agreement executed by an authorised
|
|
29
|
+
representative of KoderLabs is the ONLY mechanism by which any rights may be
|
|
30
|
+
granted.
|
|
31
|
+
|
|
32
|
+
================================================================================
|
|
33
|
+
2. PROHIBITED ACTIVITIES (NON-EXHAUSTIVE)
|
|
34
|
+
================================================================================
|
|
35
|
+
|
|
36
|
+
Without prior signed written permission from KoderLabs, the following are
|
|
37
|
+
expressly PROHIBITED and constitute infringement, breach of contract, and
|
|
38
|
+
unauthorised use:
|
|
39
|
+
|
|
40
|
+
(a) Copying the Software in whole or in part, in any medium;
|
|
41
|
+
(b) Modifying, adapting, translating, porting, or creating derivative works
|
|
42
|
+
of the Software;
|
|
43
|
+
(c) Distributing, republishing, mirroring, hosting, transmitting,
|
|
44
|
+
sublicensing, leasing, lending, renting, selling, offering for sale,
|
|
45
|
+
bartering, gifting, or otherwise transferring the Software or any
|
|
46
|
+
portion of it;
|
|
47
|
+
(d) Forking the Software's repository, whether on GitHub, GitLab, Bitbucket,
|
|
48
|
+
Codeberg, Sourcehut, or any other version-control hosting service;
|
|
49
|
+
(e) Reverse engineering, decompiling, disassembling, deobfuscating,
|
|
50
|
+
extracting source from compiled or minified artifacts, or attempting to
|
|
51
|
+
derive the source code, algorithms, or trade secrets;
|
|
52
|
+
(f) Removing, altering, or obscuring any copyright, trademark, license,
|
|
53
|
+
attribution, or proprietary notice;
|
|
54
|
+
(g) Using the Software, in whole or in part, to train, fine-tune,
|
|
55
|
+
evaluate, or benchmark any machine-learning model, embedding model, or
|
|
56
|
+
AI system;
|
|
57
|
+
(h) Using the Software to provide a hosted service, SaaS offering,
|
|
58
|
+
managed offering, or any form of public or commercial offering;
|
|
59
|
+
(i) Using the Software in any production, staging, development, evaluation,
|
|
60
|
+
or testing capacity, whether commercial or non-commercial;
|
|
61
|
+
(j) Bypassing, disabling, or attempting to circumvent any technical
|
|
62
|
+
protection measure (license check, telemetry, signature verification,
|
|
63
|
+
etc.) embedded in the Software;
|
|
64
|
+
(k) Combining or integrating the Software with any work licensed under a
|
|
65
|
+
copyleft licence (including but not limited to GPL, AGPL, LGPL, MPL,
|
|
66
|
+
EPL) in a manner that would purport to relicense the Software;
|
|
67
|
+
(l) Filing, prosecuting, or threatening patent litigation against KoderLabs
|
|
68
|
+
or its customers based on any feature, design, or behaviour of the
|
|
69
|
+
Software ("defensive termination" — any such action automatically and
|
|
70
|
+
immediately terminates any rights granted to the litigant elsewhere).
|
|
71
|
+
|
|
72
|
+
================================================================================
|
|
73
|
+
3. NO IMPLIED RIGHT TO INTERNAL USE
|
|
74
|
+
================================================================================
|
|
75
|
+
|
|
76
|
+
The Software is NOT licensed for internal evaluation, internal production,
|
|
77
|
+
internal testing, or any other internal use unless and until a separate
|
|
78
|
+
written commercial licence is executed. Possession of a copy of the Software,
|
|
79
|
+
by whatever means, confers no right to execute, run, deploy, or use it.
|
|
80
|
+
|
|
81
|
+
================================================================================
|
|
82
|
+
4. NO PATENT, TRADEMARK, OR OTHER IP GRANT
|
|
83
|
+
================================================================================
|
|
84
|
+
|
|
85
|
+
No patent licence, trademark licence, trade-secret disclosure, design-right
|
|
86
|
+
licence, or any other intellectual-property licence is granted under this
|
|
87
|
+
notice. KoderLabs retains all such rights.
|
|
88
|
+
|
|
89
|
+
================================================================================
|
|
90
|
+
5. CONFIDENTIALITY
|
|
91
|
+
================================================================================
|
|
92
|
+
|
|
93
|
+
The Software contains trade secrets and confidential information of
|
|
94
|
+
KoderLabs. Any party in possession of the Software shall (a) treat it as
|
|
95
|
+
confidential, (b) take reasonable measures to prevent unauthorised access or
|
|
96
|
+
disclosure, and (c) not disclose, publish, or make available the Software or
|
|
97
|
+
any portion thereof to any third party.
|
|
98
|
+
|
|
99
|
+
================================================================================
|
|
100
|
+
6. AUTOMATIC TERMINATION
|
|
101
|
+
================================================================================
|
|
102
|
+
|
|
103
|
+
Any rights that may exist under a separate written agreement terminate
|
|
104
|
+
AUTOMATICALLY AND IMMEDIATELY upon any breach of this notice, without notice
|
|
105
|
+
and without judicial action. Upon termination, the breaching party shall
|
|
106
|
+
immediately destroy all copies of the Software in its possession or control
|
|
107
|
+
and certify destruction in writing to KoderLabs.
|
|
108
|
+
|
|
109
|
+
================================================================================
|
|
110
|
+
7. NO WARRANTY
|
|
111
|
+
================================================================================
|
|
112
|
+
|
|
113
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
114
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
115
|
+
FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, ACCURACY, RELIABILITY,
|
|
116
|
+
TITLE, AVAILABILITY, OR THAT THE SOFTWARE WILL OPERATE UNINTERRUPTED OR
|
|
117
|
+
ERROR-FREE.
|
|
118
|
+
|
|
119
|
+
================================================================================
|
|
120
|
+
8. NO LIABILITY
|
|
121
|
+
================================================================================
|
|
122
|
+
|
|
123
|
+
IN NO EVENT SHALL KODERLABS OR ITS AFFILIATES, OFFICERS, EMPLOYEES, AGENTS,
|
|
124
|
+
LICENSORS, OR CONTRIBUTORS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
|
|
125
|
+
LIABILITY (INCLUDING DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
|
126
|
+
CONSEQUENTIAL, PUNITIVE, LOST PROFITS, LOST DATA, OR BUSINESS INTERRUPTION),
|
|
127
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT
|
|
128
|
+
LIABILITY, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE
|
|
129
|
+
SOFTWARE OR THE USE OF OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF
|
|
130
|
+
THE POSSIBILITY OF SUCH DAMAGE. IN NO EVENT SHALL KODERLABS' TOTAL CUMULATIVE
|
|
131
|
+
LIABILITY EXCEED ONE U.S. DOLLAR (USD 1.00).
|
|
132
|
+
|
|
133
|
+
================================================================================
|
|
134
|
+
9. EQUITABLE RELIEF
|
|
135
|
+
================================================================================
|
|
136
|
+
|
|
137
|
+
The parties acknowledge that any breach of this notice would cause
|
|
138
|
+
irreparable harm to KoderLabs for which monetary damages would be inadequate.
|
|
139
|
+
KoderLabs is therefore entitled, in addition to all other remedies available
|
|
140
|
+
at law, to specific performance and injunctive relief without the need to
|
|
141
|
+
post bond.
|
|
142
|
+
|
|
143
|
+
================================================================================
|
|
144
|
+
10. GOVERNING LAW AND VENUE
|
|
145
|
+
================================================================================
|
|
146
|
+
|
|
147
|
+
This notice shall be governed by and construed in accordance with the laws
|
|
148
|
+
of the Islamic Republic of Pakistan, without regard to its conflict-of-laws
|
|
149
|
+
principles. Any dispute arising out of or in connection with this notice
|
|
150
|
+
shall be subject to the exclusive jurisdiction of the courts of Karachi,
|
|
151
|
+
Pakistan.
|
|
152
|
+
|
|
153
|
+
The United Nations Convention on Contracts for the International Sale of
|
|
154
|
+
Goods shall not apply.
|
|
155
|
+
|
|
156
|
+
================================================================================
|
|
157
|
+
11. SEVERABILITY AND ENTIRE NOTICE
|
|
158
|
+
================================================================================
|
|
159
|
+
|
|
160
|
+
If any provision of this notice is held invalid or unenforceable, the
|
|
161
|
+
remaining provisions shall continue in full force and effect. This notice,
|
|
162
|
+
together with any separate signed written licence executed between KoderLabs
|
|
163
|
+
and a licensee, constitutes the entire agreement concerning the Software and
|
|
164
|
+
supersedes all prior or contemporaneous understandings.
|
|
165
|
+
|
|
166
|
+
================================================================================
|
|
167
|
+
12. CONTACT
|
|
168
|
+
================================================================================
|
|
169
|
+
|
|
170
|
+
For licensing inquiries, audit requests, or notice of suspected
|
|
171
|
+
infringement, contact:
|
|
172
|
+
|
|
173
|
+
KoderLabs
|
|
174
|
+
Attn: Jawaid Gadiwala
|
|
175
|
+
Email: jawaidgadiwala@gmail.com
|
|
176
|
+
|
|
177
|
+
================================================================================
|
|
178
|
+
END OF LICENCE
|
|
179
|
+
================================================================================
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Proprietary Software
|
|
2
|
+
|
|
3
|
+
KoderLabs proprietary. All rights reserved.
|
|
4
|
+
|
|
5
|
+
See the bundled `LICENSE` for terms. No grant of any rights, express or
|
|
6
|
+
implied, is conferred by access to or possession of this package. A
|
|
7
|
+
separate signed written licence from KoderLabs is required for any use.
|
|
8
|
+
|
|
9
|
+
Licensing inquiries: jawaidgadiwala@gmail.com
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
ACCESS_KEY_PREFIX: () => ACCESS_KEY_PREFIX,
|
|
25
|
+
ALL_SCOPES: () => ALL_SCOPES,
|
|
26
|
+
DEFAULT_INGEST_SCOPES: () => DEFAULT_INGEST_SCOPES,
|
|
27
|
+
DEFAULT_MANAGEMENT_SCOPES: () => DEFAULT_MANAGEMENT_SCOPES,
|
|
28
|
+
EVENT_KIND_VALUES: () => EVENT_KIND_VALUES,
|
|
29
|
+
INGEST_EVENT_KIND_VALUES: () => INGEST_EVENT_KIND_VALUES,
|
|
30
|
+
PROJECT_ID_PREFIX: () => PROJECT_ID_PREFIX,
|
|
31
|
+
PROJECT_KEY_KINDS: () => PROJECT_KEY_KINDS,
|
|
32
|
+
PROJECT_KEY_PREFIX: () => PROJECT_KEY_PREFIX,
|
|
33
|
+
PROJECT_KEY_TYPES: () => PROJECT_KEY_TYPES,
|
|
34
|
+
SCOPE: () => SCOPE,
|
|
35
|
+
SECRET_KEY_PREFIX: () => SECRET_KEY_PREFIX,
|
|
36
|
+
isAccessKey: () => isAccessKey,
|
|
37
|
+
isProjectId: () => isProjectId,
|
|
38
|
+
isSecretKey: () => isSecretKey,
|
|
39
|
+
isValidScope: () => isValidScope
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(index_exports);
|
|
42
|
+
|
|
43
|
+
// src/keys.ts
|
|
44
|
+
var PROJECT_ID_PREFIX = "proj_";
|
|
45
|
+
var ACCESS_KEY_PREFIX = "ik_live_";
|
|
46
|
+
var SECRET_KEY_PREFIX = "sk_live_";
|
|
47
|
+
var PROJECT_KEY_TYPES = [
|
|
48
|
+
"ingest",
|
|
49
|
+
"management"
|
|
50
|
+
];
|
|
51
|
+
var PROJECT_KEY_PREFIX = {
|
|
52
|
+
ingest: ACCESS_KEY_PREFIX,
|
|
53
|
+
management: SECRET_KEY_PREFIX
|
|
54
|
+
};
|
|
55
|
+
var PROJECT_KEY_KINDS = PROJECT_KEY_TYPES;
|
|
56
|
+
function isProjectId(v) {
|
|
57
|
+
return v.startsWith(PROJECT_ID_PREFIX);
|
|
58
|
+
}
|
|
59
|
+
__name(isProjectId, "isProjectId");
|
|
60
|
+
function isAccessKey(v) {
|
|
61
|
+
return v.startsWith(ACCESS_KEY_PREFIX);
|
|
62
|
+
}
|
|
63
|
+
__name(isAccessKey, "isAccessKey");
|
|
64
|
+
function isSecretKey(v) {
|
|
65
|
+
return v.startsWith(SECRET_KEY_PREFIX);
|
|
66
|
+
}
|
|
67
|
+
__name(isSecretKey, "isSecretKey");
|
|
68
|
+
|
|
69
|
+
// src/events.ts
|
|
70
|
+
var EVENT_KIND_VALUES = [
|
|
71
|
+
"bug_report",
|
|
72
|
+
"error",
|
|
73
|
+
"breadcrumb",
|
|
74
|
+
"session",
|
|
75
|
+
"web_vital"
|
|
76
|
+
];
|
|
77
|
+
var INGEST_EVENT_KIND_VALUES = [
|
|
78
|
+
"bug_report",
|
|
79
|
+
"error",
|
|
80
|
+
"breadcrumb",
|
|
81
|
+
"web_vital"
|
|
82
|
+
];
|
|
83
|
+
|
|
84
|
+
// src/scopes.ts
|
|
85
|
+
var SCOPE = {
|
|
86
|
+
WIDGET_SUBMIT: "widget:submit",
|
|
87
|
+
EVENT_READ: "event:read",
|
|
88
|
+
EVENT_WRITE: "event:write",
|
|
89
|
+
PROJECT_READ: "project:read",
|
|
90
|
+
PROJECT_WRITE: "project:write",
|
|
91
|
+
TICKET_READ: "ticket:read",
|
|
92
|
+
TICKET_WRITE: "ticket:write",
|
|
93
|
+
TEAM_READ: "team:read",
|
|
94
|
+
TEAM_WRITE: "team:write",
|
|
95
|
+
BULK_ADMIN: "bulk:admin"
|
|
96
|
+
};
|
|
97
|
+
var ALL_SCOPES = Object.values(SCOPE);
|
|
98
|
+
var DEFAULT_INGEST_SCOPES = [
|
|
99
|
+
SCOPE.WIDGET_SUBMIT,
|
|
100
|
+
SCOPE.EVENT_WRITE
|
|
101
|
+
];
|
|
102
|
+
var DEFAULT_MANAGEMENT_SCOPES = [
|
|
103
|
+
SCOPE.EVENT_READ,
|
|
104
|
+
SCOPE.EVENT_WRITE,
|
|
105
|
+
SCOPE.PROJECT_READ,
|
|
106
|
+
SCOPE.TICKET_READ,
|
|
107
|
+
SCOPE.TICKET_WRITE
|
|
108
|
+
];
|
|
109
|
+
function isValidScope(s) {
|
|
110
|
+
return ALL_SCOPES.includes(s);
|
|
111
|
+
}
|
|
112
|
+
__name(isValidScope, "isValidScope");
|
|
113
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
114
|
+
0 && (module.exports = {
|
|
115
|
+
ACCESS_KEY_PREFIX,
|
|
116
|
+
ALL_SCOPES,
|
|
117
|
+
DEFAULT_INGEST_SCOPES,
|
|
118
|
+
DEFAULT_MANAGEMENT_SCOPES,
|
|
119
|
+
EVENT_KIND_VALUES,
|
|
120
|
+
INGEST_EVENT_KIND_VALUES,
|
|
121
|
+
PROJECT_ID_PREFIX,
|
|
122
|
+
PROJECT_KEY_KINDS,
|
|
123
|
+
PROJECT_KEY_PREFIX,
|
|
124
|
+
PROJECT_KEY_TYPES,
|
|
125
|
+
SCOPE,
|
|
126
|
+
SECRET_KEY_PREFIX,
|
|
127
|
+
isAccessKey,
|
|
128
|
+
isProjectId,
|
|
129
|
+
isSecretKey,
|
|
130
|
+
isValidScope
|
|
131
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
declare const projectIdBrand: unique symbol;
|
|
2
|
+
declare const accessKeyBrand: unique symbol;
|
|
3
|
+
declare const secretKeyBrand: unique symbol;
|
|
4
|
+
type ProjectId = string & {
|
|
5
|
+
readonly [projectIdBrand]: true;
|
|
6
|
+
};
|
|
7
|
+
type AccessKey = string & {
|
|
8
|
+
readonly [accessKeyBrand]: true;
|
|
9
|
+
};
|
|
10
|
+
type SecretKey = string & {
|
|
11
|
+
readonly [secretKeyBrand]: true;
|
|
12
|
+
};
|
|
13
|
+
declare const PROJECT_ID_PREFIX = "proj_";
|
|
14
|
+
declare const ACCESS_KEY_PREFIX = "ik_live_";
|
|
15
|
+
declare const SECRET_KEY_PREFIX = "sk_live_";
|
|
16
|
+
/**
|
|
17
|
+
* Project key type. `ingest` mints an access (publishable) key used by the
|
|
18
|
+
* browser SDK; `management` mints a secret key used server-to-server / MCP.
|
|
19
|
+
*/
|
|
20
|
+
type ProjectKeyType = 'ingest' | 'management';
|
|
21
|
+
declare const PROJECT_KEY_TYPES: readonly ProjectKeyType[];
|
|
22
|
+
/** Prefix table keyed by type — single source of truth for plaintext minting. */
|
|
23
|
+
declare const PROJECT_KEY_PREFIX: Record<ProjectKeyType, string>;
|
|
24
|
+
/** @deprecated use {@link ProjectKeyType} */
|
|
25
|
+
type ProjectKeyKind = ProjectKeyType;
|
|
26
|
+
/** @deprecated use {@link PROJECT_KEY_TYPES} */
|
|
27
|
+
declare const PROJECT_KEY_KINDS: readonly ProjectKeyType[];
|
|
28
|
+
declare function isProjectId(v: string): v is ProjectId;
|
|
29
|
+
declare function isAccessKey(v: string): v is AccessKey;
|
|
30
|
+
declare function isSecretKey(v: string): v is SecretKey;
|
|
31
|
+
|
|
32
|
+
type Serializable = string | number | boolean | null | Serializable[] | {
|
|
33
|
+
[key: string]: Serializable;
|
|
34
|
+
};
|
|
35
|
+
type EventKind = 'bug_report' | 'error' | 'breadcrumb' | 'session' | 'web_vital';
|
|
36
|
+
/** All event kinds the SDK transport can emit. Single source of truth for
|
|
37
|
+
* validation pipes (class-validator `@IsIn`) and runtime checks. */
|
|
38
|
+
declare const EVENT_KIND_VALUES: readonly EventKind[];
|
|
39
|
+
/** Subset accepted by the v1 ingest endpoint (session events stream
|
|
40
|
+
* separately via the replay channel, not the event submission DTO). */
|
|
41
|
+
type IngestEventKind = Exclude<EventKind, 'session'>;
|
|
42
|
+
declare const INGEST_EVENT_KIND_VALUES: readonly IngestEventKind[];
|
|
43
|
+
type WebVitalName = 'LCP' | 'INP' | 'CLS' | 'FCP' | 'TTFB';
|
|
44
|
+
interface WebVitalEvent extends EventEnvelopeBase<'web_vital'> {
|
|
45
|
+
metric: WebVitalName;
|
|
46
|
+
value: number;
|
|
47
|
+
rating: 'good' | 'needs-improvement' | 'poor';
|
|
48
|
+
/** Unique measurement id from web-vitals lib (allows dedup) */
|
|
49
|
+
measurementId?: string;
|
|
50
|
+
navigationType?: string;
|
|
51
|
+
}
|
|
52
|
+
interface EventEnvelopeBase<K extends EventKind> {
|
|
53
|
+
kind: K;
|
|
54
|
+
ts: string;
|
|
55
|
+
release?: string;
|
|
56
|
+
environment?: string;
|
|
57
|
+
user?: {
|
|
58
|
+
id?: string;
|
|
59
|
+
email?: string;
|
|
60
|
+
username?: string;
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
};
|
|
63
|
+
url: string;
|
|
64
|
+
userAgent: string;
|
|
65
|
+
viewport: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
custom?: Record<string, Serializable>;
|
|
70
|
+
}
|
|
71
|
+
interface BugReportEvent extends EventEnvelopeBase<'bug_report'> {
|
|
72
|
+
title?: string;
|
|
73
|
+
description: string;
|
|
74
|
+
email?: string;
|
|
75
|
+
annotations?: Array<{
|
|
76
|
+
type: 'highlight' | 'hide';
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
w: number;
|
|
80
|
+
h: number;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
/** Stack frame as emitted by browser/RN SDK parsers and ingested by the API. */
|
|
84
|
+
interface Frame {
|
|
85
|
+
filename: string | null;
|
|
86
|
+
function: string | null;
|
|
87
|
+
lineno: number | null;
|
|
88
|
+
colno: number | null;
|
|
89
|
+
in_app: boolean;
|
|
90
|
+
}
|
|
91
|
+
type ErrorLevel = 'fatal' | 'error' | 'warning' | 'info' | 'debug';
|
|
92
|
+
interface ErrorEvent extends EventEnvelopeBase<'error'> {
|
|
93
|
+
exception: {
|
|
94
|
+
type: string;
|
|
95
|
+
value: string;
|
|
96
|
+
/** Parsed frames — canonical shape consumed by apps/api error.handler */
|
|
97
|
+
stacktrace: {
|
|
98
|
+
frames: Frame[];
|
|
99
|
+
};
|
|
100
|
+
/** Raw stack string (optional, retained for forensic / unparsed transports) */
|
|
101
|
+
stack?: string;
|
|
102
|
+
/** Origin of capture, optional for backwards-compat */
|
|
103
|
+
mechanism?: 'onerror' | 'unhandledrejection' | 'notify';
|
|
104
|
+
};
|
|
105
|
+
level: ErrorLevel;
|
|
106
|
+
breadcrumbs?: Breadcrumb[];
|
|
107
|
+
fingerprint?: string[];
|
|
108
|
+
/** Captured network requests preceding the error (sdk-network ring). */
|
|
109
|
+
networkRing?: unknown[];
|
|
110
|
+
/** Active feature flags at the time of the error. */
|
|
111
|
+
featureFlags?: Array<{
|
|
112
|
+
name: string;
|
|
113
|
+
variant: string | boolean | number;
|
|
114
|
+
}>;
|
|
115
|
+
/** Arbitrary key→object metadata grouped by namespace (e.g. `device`, `app`). */
|
|
116
|
+
contexts?: Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
type BreadcrumbCategory = 'xhr' | 'fetch' | 'ui' | 'navigation' | 'console' | 'error' | 'user' | 'http' | 'custom';
|
|
119
|
+
type BreadcrumbLevel = 'debug' | 'info' | 'warning' | 'error';
|
|
120
|
+
interface Breadcrumb {
|
|
121
|
+
/** ISO 8601 timestamp. SDK writes `timestamp`; handlers do not read this
|
|
122
|
+
* field today, so the canonical name follows what the SDK + tests emit. */
|
|
123
|
+
timestamp: string;
|
|
124
|
+
category: BreadcrumbCategory;
|
|
125
|
+
message: string;
|
|
126
|
+
level?: BreadcrumbLevel;
|
|
127
|
+
data?: Record<string, unknown>;
|
|
128
|
+
}
|
|
129
|
+
type AnyEvent = BugReportEvent | ErrorEvent | WebVitalEvent;
|
|
130
|
+
|
|
131
|
+
declare const SCOPE: {
|
|
132
|
+
readonly WIDGET_SUBMIT: "widget:submit";
|
|
133
|
+
readonly EVENT_READ: "event:read";
|
|
134
|
+
readonly EVENT_WRITE: "event:write";
|
|
135
|
+
readonly PROJECT_READ: "project:read";
|
|
136
|
+
readonly PROJECT_WRITE: "project:write";
|
|
137
|
+
readonly TICKET_READ: "ticket:read";
|
|
138
|
+
readonly TICKET_WRITE: "ticket:write";
|
|
139
|
+
readonly TEAM_READ: "team:read";
|
|
140
|
+
readonly TEAM_WRITE: "team:write";
|
|
141
|
+
readonly BULK_ADMIN: "bulk:admin";
|
|
142
|
+
};
|
|
143
|
+
type Scope = typeof SCOPE[keyof typeof SCOPE];
|
|
144
|
+
declare const ALL_SCOPES: Scope[];
|
|
145
|
+
declare const DEFAULT_INGEST_SCOPES: Scope[];
|
|
146
|
+
declare const DEFAULT_MANAGEMENT_SCOPES: Scope[];
|
|
147
|
+
declare function isValidScope(s: string): s is Scope;
|
|
148
|
+
|
|
149
|
+
export { ACCESS_KEY_PREFIX, ALL_SCOPES, type AccessKey, type AnyEvent, type Breadcrumb, type BreadcrumbCategory, type BreadcrumbLevel, type BugReportEvent, DEFAULT_INGEST_SCOPES, DEFAULT_MANAGEMENT_SCOPES, EVENT_KIND_VALUES, type ErrorEvent, type ErrorLevel, type EventEnvelopeBase, type EventKind, type Frame, INGEST_EVENT_KIND_VALUES, type IngestEventKind, PROJECT_ID_PREFIX, PROJECT_KEY_KINDS, PROJECT_KEY_PREFIX, PROJECT_KEY_TYPES, type ProjectId, type ProjectKeyKind, type ProjectKeyType, SCOPE, SECRET_KEY_PREFIX, type Scope, type SecretKey, type Serializable, type WebVitalEvent, type WebVitalName, isAccessKey, isProjectId, isSecretKey, isValidScope };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
declare const projectIdBrand: unique symbol;
|
|
2
|
+
declare const accessKeyBrand: unique symbol;
|
|
3
|
+
declare const secretKeyBrand: unique symbol;
|
|
4
|
+
type ProjectId = string & {
|
|
5
|
+
readonly [projectIdBrand]: true;
|
|
6
|
+
};
|
|
7
|
+
type AccessKey = string & {
|
|
8
|
+
readonly [accessKeyBrand]: true;
|
|
9
|
+
};
|
|
10
|
+
type SecretKey = string & {
|
|
11
|
+
readonly [secretKeyBrand]: true;
|
|
12
|
+
};
|
|
13
|
+
declare const PROJECT_ID_PREFIX = "proj_";
|
|
14
|
+
declare const ACCESS_KEY_PREFIX = "ik_live_";
|
|
15
|
+
declare const SECRET_KEY_PREFIX = "sk_live_";
|
|
16
|
+
/**
|
|
17
|
+
* Project key type. `ingest` mints an access (publishable) key used by the
|
|
18
|
+
* browser SDK; `management` mints a secret key used server-to-server / MCP.
|
|
19
|
+
*/
|
|
20
|
+
type ProjectKeyType = 'ingest' | 'management';
|
|
21
|
+
declare const PROJECT_KEY_TYPES: readonly ProjectKeyType[];
|
|
22
|
+
/** Prefix table keyed by type — single source of truth for plaintext minting. */
|
|
23
|
+
declare const PROJECT_KEY_PREFIX: Record<ProjectKeyType, string>;
|
|
24
|
+
/** @deprecated use {@link ProjectKeyType} */
|
|
25
|
+
type ProjectKeyKind = ProjectKeyType;
|
|
26
|
+
/** @deprecated use {@link PROJECT_KEY_TYPES} */
|
|
27
|
+
declare const PROJECT_KEY_KINDS: readonly ProjectKeyType[];
|
|
28
|
+
declare function isProjectId(v: string): v is ProjectId;
|
|
29
|
+
declare function isAccessKey(v: string): v is AccessKey;
|
|
30
|
+
declare function isSecretKey(v: string): v is SecretKey;
|
|
31
|
+
|
|
32
|
+
type Serializable = string | number | boolean | null | Serializable[] | {
|
|
33
|
+
[key: string]: Serializable;
|
|
34
|
+
};
|
|
35
|
+
type EventKind = 'bug_report' | 'error' | 'breadcrumb' | 'session' | 'web_vital';
|
|
36
|
+
/** All event kinds the SDK transport can emit. Single source of truth for
|
|
37
|
+
* validation pipes (class-validator `@IsIn`) and runtime checks. */
|
|
38
|
+
declare const EVENT_KIND_VALUES: readonly EventKind[];
|
|
39
|
+
/** Subset accepted by the v1 ingest endpoint (session events stream
|
|
40
|
+
* separately via the replay channel, not the event submission DTO). */
|
|
41
|
+
type IngestEventKind = Exclude<EventKind, 'session'>;
|
|
42
|
+
declare const INGEST_EVENT_KIND_VALUES: readonly IngestEventKind[];
|
|
43
|
+
type WebVitalName = 'LCP' | 'INP' | 'CLS' | 'FCP' | 'TTFB';
|
|
44
|
+
interface WebVitalEvent extends EventEnvelopeBase<'web_vital'> {
|
|
45
|
+
metric: WebVitalName;
|
|
46
|
+
value: number;
|
|
47
|
+
rating: 'good' | 'needs-improvement' | 'poor';
|
|
48
|
+
/** Unique measurement id from web-vitals lib (allows dedup) */
|
|
49
|
+
measurementId?: string;
|
|
50
|
+
navigationType?: string;
|
|
51
|
+
}
|
|
52
|
+
interface EventEnvelopeBase<K extends EventKind> {
|
|
53
|
+
kind: K;
|
|
54
|
+
ts: string;
|
|
55
|
+
release?: string;
|
|
56
|
+
environment?: string;
|
|
57
|
+
user?: {
|
|
58
|
+
id?: string;
|
|
59
|
+
email?: string;
|
|
60
|
+
username?: string;
|
|
61
|
+
[key: string]: unknown;
|
|
62
|
+
};
|
|
63
|
+
url: string;
|
|
64
|
+
userAgent: string;
|
|
65
|
+
viewport: {
|
|
66
|
+
width: number;
|
|
67
|
+
height: number;
|
|
68
|
+
};
|
|
69
|
+
custom?: Record<string, Serializable>;
|
|
70
|
+
}
|
|
71
|
+
interface BugReportEvent extends EventEnvelopeBase<'bug_report'> {
|
|
72
|
+
title?: string;
|
|
73
|
+
description: string;
|
|
74
|
+
email?: string;
|
|
75
|
+
annotations?: Array<{
|
|
76
|
+
type: 'highlight' | 'hide';
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
w: number;
|
|
80
|
+
h: number;
|
|
81
|
+
}>;
|
|
82
|
+
}
|
|
83
|
+
/** Stack frame as emitted by browser/RN SDK parsers and ingested by the API. */
|
|
84
|
+
interface Frame {
|
|
85
|
+
filename: string | null;
|
|
86
|
+
function: string | null;
|
|
87
|
+
lineno: number | null;
|
|
88
|
+
colno: number | null;
|
|
89
|
+
in_app: boolean;
|
|
90
|
+
}
|
|
91
|
+
type ErrorLevel = 'fatal' | 'error' | 'warning' | 'info' | 'debug';
|
|
92
|
+
interface ErrorEvent extends EventEnvelopeBase<'error'> {
|
|
93
|
+
exception: {
|
|
94
|
+
type: string;
|
|
95
|
+
value: string;
|
|
96
|
+
/** Parsed frames — canonical shape consumed by apps/api error.handler */
|
|
97
|
+
stacktrace: {
|
|
98
|
+
frames: Frame[];
|
|
99
|
+
};
|
|
100
|
+
/** Raw stack string (optional, retained for forensic / unparsed transports) */
|
|
101
|
+
stack?: string;
|
|
102
|
+
/** Origin of capture, optional for backwards-compat */
|
|
103
|
+
mechanism?: 'onerror' | 'unhandledrejection' | 'notify';
|
|
104
|
+
};
|
|
105
|
+
level: ErrorLevel;
|
|
106
|
+
breadcrumbs?: Breadcrumb[];
|
|
107
|
+
fingerprint?: string[];
|
|
108
|
+
/** Captured network requests preceding the error (sdk-network ring). */
|
|
109
|
+
networkRing?: unknown[];
|
|
110
|
+
/** Active feature flags at the time of the error. */
|
|
111
|
+
featureFlags?: Array<{
|
|
112
|
+
name: string;
|
|
113
|
+
variant: string | boolean | number;
|
|
114
|
+
}>;
|
|
115
|
+
/** Arbitrary key→object metadata grouped by namespace (e.g. `device`, `app`). */
|
|
116
|
+
contexts?: Record<string, unknown>;
|
|
117
|
+
}
|
|
118
|
+
type BreadcrumbCategory = 'xhr' | 'fetch' | 'ui' | 'navigation' | 'console' | 'error' | 'user' | 'http' | 'custom';
|
|
119
|
+
type BreadcrumbLevel = 'debug' | 'info' | 'warning' | 'error';
|
|
120
|
+
interface Breadcrumb {
|
|
121
|
+
/** ISO 8601 timestamp. SDK writes `timestamp`; handlers do not read this
|
|
122
|
+
* field today, so the canonical name follows what the SDK + tests emit. */
|
|
123
|
+
timestamp: string;
|
|
124
|
+
category: BreadcrumbCategory;
|
|
125
|
+
message: string;
|
|
126
|
+
level?: BreadcrumbLevel;
|
|
127
|
+
data?: Record<string, unknown>;
|
|
128
|
+
}
|
|
129
|
+
type AnyEvent = BugReportEvent | ErrorEvent | WebVitalEvent;
|
|
130
|
+
|
|
131
|
+
declare const SCOPE: {
|
|
132
|
+
readonly WIDGET_SUBMIT: "widget:submit";
|
|
133
|
+
readonly EVENT_READ: "event:read";
|
|
134
|
+
readonly EVENT_WRITE: "event:write";
|
|
135
|
+
readonly PROJECT_READ: "project:read";
|
|
136
|
+
readonly PROJECT_WRITE: "project:write";
|
|
137
|
+
readonly TICKET_READ: "ticket:read";
|
|
138
|
+
readonly TICKET_WRITE: "ticket:write";
|
|
139
|
+
readonly TEAM_READ: "team:read";
|
|
140
|
+
readonly TEAM_WRITE: "team:write";
|
|
141
|
+
readonly BULK_ADMIN: "bulk:admin";
|
|
142
|
+
};
|
|
143
|
+
type Scope = typeof SCOPE[keyof typeof SCOPE];
|
|
144
|
+
declare const ALL_SCOPES: Scope[];
|
|
145
|
+
declare const DEFAULT_INGEST_SCOPES: Scope[];
|
|
146
|
+
declare const DEFAULT_MANAGEMENT_SCOPES: Scope[];
|
|
147
|
+
declare function isValidScope(s: string): s is Scope;
|
|
148
|
+
|
|
149
|
+
export { ACCESS_KEY_PREFIX, ALL_SCOPES, type AccessKey, type AnyEvent, type Breadcrumb, type BreadcrumbCategory, type BreadcrumbLevel, type BugReportEvent, DEFAULT_INGEST_SCOPES, DEFAULT_MANAGEMENT_SCOPES, EVENT_KIND_VALUES, type ErrorEvent, type ErrorLevel, type EventEnvelopeBase, type EventKind, type Frame, INGEST_EVENT_KIND_VALUES, type IngestEventKind, PROJECT_ID_PREFIX, PROJECT_KEY_KINDS, PROJECT_KEY_PREFIX, PROJECT_KEY_TYPES, type ProjectId, type ProjectKeyKind, type ProjectKeyType, SCOPE, SECRET_KEY_PREFIX, type Scope, type SecretKey, type Serializable, type WebVitalEvent, type WebVitalName, isAccessKey, isProjectId, isSecretKey, isValidScope };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/keys.ts
|
|
5
|
+
var PROJECT_ID_PREFIX = "proj_";
|
|
6
|
+
var ACCESS_KEY_PREFIX = "ik_live_";
|
|
7
|
+
var SECRET_KEY_PREFIX = "sk_live_";
|
|
8
|
+
var PROJECT_KEY_TYPES = [
|
|
9
|
+
"ingest",
|
|
10
|
+
"management"
|
|
11
|
+
];
|
|
12
|
+
var PROJECT_KEY_PREFIX = {
|
|
13
|
+
ingest: ACCESS_KEY_PREFIX,
|
|
14
|
+
management: SECRET_KEY_PREFIX
|
|
15
|
+
};
|
|
16
|
+
var PROJECT_KEY_KINDS = PROJECT_KEY_TYPES;
|
|
17
|
+
function isProjectId(v) {
|
|
18
|
+
return v.startsWith(PROJECT_ID_PREFIX);
|
|
19
|
+
}
|
|
20
|
+
__name(isProjectId, "isProjectId");
|
|
21
|
+
function isAccessKey(v) {
|
|
22
|
+
return v.startsWith(ACCESS_KEY_PREFIX);
|
|
23
|
+
}
|
|
24
|
+
__name(isAccessKey, "isAccessKey");
|
|
25
|
+
function isSecretKey(v) {
|
|
26
|
+
return v.startsWith(SECRET_KEY_PREFIX);
|
|
27
|
+
}
|
|
28
|
+
__name(isSecretKey, "isSecretKey");
|
|
29
|
+
|
|
30
|
+
// src/events.ts
|
|
31
|
+
var EVENT_KIND_VALUES = [
|
|
32
|
+
"bug_report",
|
|
33
|
+
"error",
|
|
34
|
+
"breadcrumb",
|
|
35
|
+
"session",
|
|
36
|
+
"web_vital"
|
|
37
|
+
];
|
|
38
|
+
var INGEST_EVENT_KIND_VALUES = [
|
|
39
|
+
"bug_report",
|
|
40
|
+
"error",
|
|
41
|
+
"breadcrumb",
|
|
42
|
+
"web_vital"
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
// src/scopes.ts
|
|
46
|
+
var SCOPE = {
|
|
47
|
+
WIDGET_SUBMIT: "widget:submit",
|
|
48
|
+
EVENT_READ: "event:read",
|
|
49
|
+
EVENT_WRITE: "event:write",
|
|
50
|
+
PROJECT_READ: "project:read",
|
|
51
|
+
PROJECT_WRITE: "project:write",
|
|
52
|
+
TICKET_READ: "ticket:read",
|
|
53
|
+
TICKET_WRITE: "ticket:write",
|
|
54
|
+
TEAM_READ: "team:read",
|
|
55
|
+
TEAM_WRITE: "team:write",
|
|
56
|
+
BULK_ADMIN: "bulk:admin"
|
|
57
|
+
};
|
|
58
|
+
var ALL_SCOPES = Object.values(SCOPE);
|
|
59
|
+
var DEFAULT_INGEST_SCOPES = [
|
|
60
|
+
SCOPE.WIDGET_SUBMIT,
|
|
61
|
+
SCOPE.EVENT_WRITE
|
|
62
|
+
];
|
|
63
|
+
var DEFAULT_MANAGEMENT_SCOPES = [
|
|
64
|
+
SCOPE.EVENT_READ,
|
|
65
|
+
SCOPE.EVENT_WRITE,
|
|
66
|
+
SCOPE.PROJECT_READ,
|
|
67
|
+
SCOPE.TICKET_READ,
|
|
68
|
+
SCOPE.TICKET_WRITE
|
|
69
|
+
];
|
|
70
|
+
function isValidScope(s) {
|
|
71
|
+
return ALL_SCOPES.includes(s);
|
|
72
|
+
}
|
|
73
|
+
__name(isValidScope, "isValidScope");
|
|
74
|
+
export {
|
|
75
|
+
ACCESS_KEY_PREFIX,
|
|
76
|
+
ALL_SCOPES,
|
|
77
|
+
DEFAULT_INGEST_SCOPES,
|
|
78
|
+
DEFAULT_MANAGEMENT_SCOPES,
|
|
79
|
+
EVENT_KIND_VALUES,
|
|
80
|
+
INGEST_EVENT_KIND_VALUES,
|
|
81
|
+
PROJECT_ID_PREFIX,
|
|
82
|
+
PROJECT_KEY_KINDS,
|
|
83
|
+
PROJECT_KEY_PREFIX,
|
|
84
|
+
PROJECT_KEY_TYPES,
|
|
85
|
+
SCOPE,
|
|
86
|
+
SECRET_KEY_PREFIX,
|
|
87
|
+
isAccessKey,
|
|
88
|
+
isProjectId,
|
|
89
|
+
isSecretKey,
|
|
90
|
+
isValidScope
|
|
91
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@koderlabs/tasks-sdk-types",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Shared TypeScript types for the InstantTasks SDK suite.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"instanttasks",
|
|
7
|
+
"sdk",
|
|
8
|
+
"types"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/jawaidgadiwala/instant-tasks/tree/main/packages/sdk-types#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/jawaidgadiwala/instant-tasks/issues"
|
|
13
|
+
},
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/jawaidgadiwala/instant-tasks.git",
|
|
17
|
+
"directory": "packages/sdk-types"
|
|
18
|
+
},
|
|
19
|
+
"license": "UNLICENSED",
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Jawaid Gadiwala",
|
|
22
|
+
"email": "jawaidgadiwala@gmail.com",
|
|
23
|
+
"url": "https://koderlabs.com"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"main": "./dist/index.cjs",
|
|
27
|
+
"module": "./dist/index.js",
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"import": "./dist/index.js",
|
|
33
|
+
"require": "./dist/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"dist",
|
|
38
|
+
"LICENSE"
|
|
39
|
+
],
|
|
40
|
+
"sideEffects": false,
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"tsup": "^8.3.0",
|
|
43
|
+
"typescript": "^5.5.0"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
},
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "restricted"
|
|
50
|
+
},
|
|
51
|
+
"scripts": {
|
|
52
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
53
|
+
"dev": "tsup src/index.ts --format esm,cjs --dts --watch"
|
|
54
|
+
}
|
|
55
|
+
}
|