@antiphony/shared 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 +21 -0
- package/README.md +50 -0
- package/dist/cjs/api-codecs.cjs +971 -0
- package/dist/cjs/api-codecs.d.cts +542 -0
- package/dist/cjs/errors/index.cjs +56 -0
- package/dist/cjs/errors/index.d.cts +45 -0
- package/dist/cjs/index.cjs +1276 -0
- package/dist/cjs/index.d.cts +11 -0
- package/dist/cjs/nsid.cjs +37 -0
- package/dist/cjs/nsid.d.cts +42 -0
- package/dist/cjs/observability/index.cjs +58 -0
- package/dist/cjs/observability/index.d.cts +1 -0
- package/dist/cjs/observability/report-error.cjs +58 -0
- package/dist/cjs/observability/report-error.d.cts +48 -0
- package/dist/cjs/types/api.cjs +726 -0
- package/dist/cjs/types/api.d.cts +494 -0
- package/dist/cjs/types/audio.cjs +835 -0
- package/dist/cjs/types/audio.d.cts +1149 -0
- package/dist/cjs/types/blob.cjs +23 -0
- package/dist/cjs/types/blob.d.cts +45 -0
- package/dist/cjs/types/channels.cjs +170 -0
- package/dist/cjs/types/channels.d.cts +262 -0
- package/dist/cjs/types/records.cjs +407 -0
- package/dist/cjs/types/records.d.cts +840 -0
- package/dist/cjs/types/storage.cjs +414 -0
- package/dist/cjs/types/storage.d.cts +197 -0
- package/dist/cjs/types/views.cjs +820 -0
- package/dist/cjs/types/views.d.cts +9806 -0
- package/dist/cjs/utils/index.cjs +8 -0
- package/dist/cjs/utils/index.d.cts +7 -0
- package/dist/esm/api-codecs.d.ts +542 -0
- package/dist/esm/api-codecs.js +6 -0
- package/dist/esm/chunk-24KIXQZK.js +6 -0
- package/dist/esm/chunk-3WZJXJNU.js +378 -0
- package/dist/esm/chunk-5EHV73BA.js +20 -0
- package/dist/esm/chunk-72G3LBUQ.js +1 -0
- package/dist/esm/chunk-7LW2FHLD.js +48 -0
- package/dist/esm/chunk-7V44CPRR.js +132 -0
- package/dist/esm/chunk-BUNMR4ZO.js +127 -0
- package/dist/esm/chunk-EA4OONDV.js +380 -0
- package/dist/esm/chunk-F2CANZZ7.js +40 -0
- package/dist/esm/chunk-ORMEWXMH.js +33 -0
- package/dist/esm/chunk-TIZRJORN.js +24 -0
- package/dist/esm/chunk-XDBKR6LW.js +32 -0
- package/dist/esm/errors/index.d.ts +45 -0
- package/dist/esm/errors/index.js +2 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/nsid.d.ts +42 -0
- package/dist/esm/nsid.js +2 -0
- package/dist/esm/observability/index.d.ts +1 -0
- package/dist/esm/observability/index.js +3 -0
- package/dist/esm/observability/report-error.d.ts +48 -0
- package/dist/esm/observability/report-error.js +2 -0
- package/dist/esm/types/api.d.ts +494 -0
- package/dist/esm/types/api.js +5 -0
- package/dist/esm/types/audio.d.ts +1149 -0
- package/dist/esm/types/audio.js +5 -0
- package/dist/esm/types/blob.d.ts +45 -0
- package/dist/esm/types/blob.js +2 -0
- package/dist/esm/types/channels.d.ts +262 -0
- package/dist/esm/types/channels.js +162 -0
- package/dist/esm/types/records.d.ts +840 -0
- package/dist/esm/types/records.js +3 -0
- package/dist/esm/types/storage.d.ts +197 -0
- package/dist/esm/types/storage.js +26 -0
- package/dist/esm/types/views.d.ts +9806 -0
- package/dist/esm/types/views.js +4 -0
- package/dist/esm/utils/index.d.ts +7 -0
- package/dist/esm/utils/index.js +2 -0
- package/package.json +82 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { BadgeResetRequestSchema, BulkReplyActionRequestSchema, ConnectorConfigInputSchema, ConnectorConfigUpdateSchema, CreateAudioPostRequest, CreateAudioPostRequestSchema, CreateOrgInviteRequestSchema, CreateOrgRequestSchema, CreatePromptRequestSchema, FcmTokenRequestSchema, PersonMergeRequestSchema, PersonNotesUpdateSchema, ScreeningRuleInputSchema, ScreeningRuleUpdateSchema, SwitchOrgRequestSchema, UpdateMemberRoleRequestSchema, UpdateOrgRequestSchema, UpdateProfileRequestSchema, UpdateReplyStatusRequestSchema } from './api-codecs.cjs';
|
|
2
|
+
export { CallForwardingConfig, CallForwardingConfigSchema, ConnectorConfigRecord, ConnectorConfigRecordSchema, ConnectorStatus, ConnectorStatusSchema, ConnectorType, ConnectorTypeSchema, FirestoreTimestamp, FirestoreTimestampSchema, OrgInviteRecord, OrgInviteRecordSchema, OrganizationMemberRecord, OrganizationMemberRecordSchema, OrganizationRecord, OrganizationRecordSchema, PersonEnrichmentRecord, PersonEnrichmentRecordSchema, PromptRecord, PromptRecordSchema, ReplyEnrichmentRecord, ReplyEnrichmentRecordSchema, ReplyRecord, ReplyRecordSchema, ScreeningRuleRecord, ScreeningRuleRecordSchema, SipEnrichment, SipEnrichmentSchema, UserRecord, UserRecordSchema, httpsUrl } from './types/records.cjs';
|
|
3
|
+
export { ContactCrmData, EnrichedReplier, EnrichedReplierSchema, HandleResolution, HandleResolutionSchema, OrgInviteView, OrgInviteViewSchema, OrgProfileData, OrgProfileDataSchema, OrganizationMemberView, OrganizationMemberViewSchema, OrganizationView, OrganizationViewSchema, ProfileView, ProfileViewAdmin, ProfileViewAdminSchema, ProfileViewBasic, ProfileViewBasicSchema, ProfileViewDetailed, ProfileViewDetailedSchema, ProfileViewSchema, ProfileViewSelf, ProfileViewSelfSchema, PromptRepliers, PromptRepliersSchema, PromptView, PromptViewPublic, PromptViewPublicSchema, PromptViewSchema, PromptWithReplies, PromptWithRepliesSchema, Replier, ReplierSchema, ReplyView, ReplyViewPublic, ReplyViewPublicSchema, ReplyViewSchema, RssSummary, RssSummarySchema, UserProfileData, UserProfileDataSchema, VoxPopEmbedWidgetProps, toProfileViewBasic, toPromptViewPublic, toReplyViewPublic } from './types/views.cjs';
|
|
4
|
+
export { ActorProfileRecord, ActorProfileRecordSchema, AudioEmbed, AudioEmbedSchema, AudioEmbedView, AudioEmbedViewSchema, AudioPostRecord, AudioPostRecordSchema, AudioPostView, AudioPostViewSchema, PostRecordPublic, PostRecordPublicSchema, ReplyRef, ReplyRefSchema, StrongRef, StrongRefSchema, TimedTranscript, TimedTranscriptSchema, TranscriptEnrichmentRecord, TranscriptEnrichmentRecordSchema, TranscriptSegment, TranscriptSegmentSchema, ViewerState, ViewerStateSchema } from './types/audio.cjs';
|
|
5
|
+
export { BlobRef, BlobRefSchema, resolveAudioUrl } from './types/blob.cjs';
|
|
6
|
+
export { ActorView, ActorViewSchema, PublicProfileDto, PublicProfileDtoSchema, PublicReplyDto, PublicReplyDtoSchema } from './types/api.cjs';
|
|
7
|
+
export { COLLECTIONS, EMBED_NSID, NSID, NsidValue, nsidForCollection } from './nsid.cjs';
|
|
8
|
+
export { ConflictError, ForbiddenError, NotFoundError, RateLimitError, ServiceError, UnauthorizedError, ValidationError } from './errors/index.cjs';
|
|
9
|
+
export { isFirestoreTimestamp } from './utils/index.cjs';
|
|
10
|
+
export { ReportedErrorEvent, buildReportedErrorEvent, reportError } from './observability/report-error.cjs';
|
|
11
|
+
import 'zod';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// nsid.ts
|
|
4
|
+
var NSID = {
|
|
5
|
+
// Legacy Vox Pop record types (deprecated; removed in Stream 4).
|
|
6
|
+
Prompt: "com.voxpop.audio.prompt",
|
|
7
|
+
Reply: "com.voxpop.audio.reply",
|
|
8
|
+
Profile: "com.voxpop.actor.profile",
|
|
9
|
+
// Antiphony canonical record types (dev.antiphony.*). Added additively in
|
|
10
|
+
// Stream 1; see lexicons/dev/antiphony/ + packages/shared/types/audio.ts.
|
|
11
|
+
AudioPost: "dev.antiphony.audio.post",
|
|
12
|
+
AudioTranscript: "dev.antiphony.audio.transcript",
|
|
13
|
+
ActorProfile: "dev.antiphony.actor.profile"
|
|
14
|
+
};
|
|
15
|
+
var EMBED_NSID = {
|
|
16
|
+
Audio: "dev.antiphony.embed.audio",
|
|
17
|
+
RecordWithAudio: "dev.antiphony.embed.recordWithAudio"
|
|
18
|
+
};
|
|
19
|
+
var COLLECTIONS = {
|
|
20
|
+
[NSID.Prompt]: "prompts",
|
|
21
|
+
[NSID.Reply]: "replies",
|
|
22
|
+
[NSID.Profile]: "users",
|
|
23
|
+
// Antiphony: one post collection + the transcript enrichment namespace.
|
|
24
|
+
[NSID.AudioPost]: "posts",
|
|
25
|
+
[NSID.AudioTranscript]: "audio_transcripts",
|
|
26
|
+
[NSID.ActorProfile]: "users"
|
|
27
|
+
};
|
|
28
|
+
function nsidForCollection(collection) {
|
|
29
|
+
const entries = Object.entries(COLLECTIONS);
|
|
30
|
+
const match = entries.find(([, col]) => col === collection);
|
|
31
|
+
return match == null ? void 0 : match[0];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.COLLECTIONS = COLLECTIONS;
|
|
35
|
+
exports.EMBED_NSID = EMBED_NSID;
|
|
36
|
+
exports.NSID = NSID;
|
|
37
|
+
exports.nsidForCollection = nsidForCollection;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AT Protocol Namespaced Identifiers (NSIDs) for Vox Pop record types.
|
|
3
|
+
*
|
|
4
|
+
* NSIDs are the canonical way to identify record types in AT Protocol.
|
|
5
|
+
* This mapping connects AT Protocol NSIDs to Firestore collection names,
|
|
6
|
+
* creating a single source of truth for the relationship.
|
|
7
|
+
*
|
|
8
|
+
* @see https://atproto.com/specs/nsid
|
|
9
|
+
*/
|
|
10
|
+
declare const NSID: {
|
|
11
|
+
readonly Prompt: "com.voxpop.audio.prompt";
|
|
12
|
+
readonly Reply: "com.voxpop.audio.reply";
|
|
13
|
+
readonly Profile: "com.voxpop.actor.profile";
|
|
14
|
+
readonly AudioPost: "dev.antiphony.audio.post";
|
|
15
|
+
readonly AudioTranscript: "dev.antiphony.audio.transcript";
|
|
16
|
+
readonly ActorProfile: "dev.antiphony.actor.profile";
|
|
17
|
+
};
|
|
18
|
+
type NsidValue = typeof NSID[keyof typeof NSID];
|
|
19
|
+
/**
|
|
20
|
+
* Antiphony embed NSIDs. Embeds live inline on a post's `embed` field, not in
|
|
21
|
+
* their own collection — kept out of `NSID`/`COLLECTIONS`.
|
|
22
|
+
*/
|
|
23
|
+
declare const EMBED_NSID: {
|
|
24
|
+
readonly Audio: "dev.antiphony.embed.audio";
|
|
25
|
+
readonly RecordWithAudio: "dev.antiphony.embed.recordWithAudio";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Maps AT Protocol record-type NSIDs to Firestore collection names.
|
|
29
|
+
* When migrating to a PDS, this mapping becomes the adapter layer.
|
|
30
|
+
*
|
|
31
|
+
* Note: `dev.antiphony.actor.profile` and the legacy `com.voxpop.actor.profile`
|
|
32
|
+
* both map to `users`. `nsidForCollection('users')` returns the legacy NSID
|
|
33
|
+
* (listed first) — preserving today's reverse-lookup behavior until Stream 4
|
|
34
|
+
* removes the legacy entry.
|
|
35
|
+
*/
|
|
36
|
+
declare const COLLECTIONS: Record<NsidValue, string>;
|
|
37
|
+
/**
|
|
38
|
+
* Reverse lookup: get the NSID for a Firestore collection name.
|
|
39
|
+
*/
|
|
40
|
+
declare function nsidForCollection(collection: string): NsidValue | undefined;
|
|
41
|
+
|
|
42
|
+
export { COLLECTIONS, EMBED_NSID, NSID, type NsidValue, nsidForCollection };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// observability/report-error.ts
|
|
21
|
+
var REPORTED_ERROR_EVENT_TYPE = "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent";
|
|
22
|
+
function serviceName() {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
return (_b = (_a = process.env.K_SERVICE) != null ? _a : process.env.SERVICE_NAME) != null ? _b : "unknown";
|
|
25
|
+
}
|
|
26
|
+
function serviceVersion() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
return (_b = (_a = process.env.COMMIT_SHA) != null ? _a : process.env.K_REVISION) != null ? _b : "dev";
|
|
29
|
+
}
|
|
30
|
+
function formatUnknownError(err) {
|
|
31
|
+
var _a;
|
|
32
|
+
if (typeof err === "string") return err;
|
|
33
|
+
try {
|
|
34
|
+
return (_a = JSON.stringify(err)) != null ? _a : String(err);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return String(err);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function buildReportedErrorEvent(err, context) {
|
|
40
|
+
var _a;
|
|
41
|
+
const error = err instanceof Error ? err : new Error(formatUnknownError(err));
|
|
42
|
+
const message = (_a = error.stack) != null ? _a : `${error.name}: ${error.message}`;
|
|
43
|
+
return __spreadValues({
|
|
44
|
+
severity: "ERROR",
|
|
45
|
+
"@type": REPORTED_ERROR_EVENT_TYPE,
|
|
46
|
+
message,
|
|
47
|
+
serviceContext: { service: serviceName(), version: serviceVersion() }
|
|
48
|
+
}, context && Object.keys(context).length > 0 ? { context } : {});
|
|
49
|
+
}
|
|
50
|
+
function reportError(err, context) {
|
|
51
|
+
try {
|
|
52
|
+
console.error(JSON.stringify(buildReportedErrorEvent(err, context)));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.buildReportedErrorEvent = buildReportedErrorEvent;
|
|
58
|
+
exports.reportError = reportError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ReportedErrorEvent, buildReportedErrorEvent, reportError } from './report-error.cjs';
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// observability/report-error.ts
|
|
21
|
+
var REPORTED_ERROR_EVENT_TYPE = "type.googleapis.com/google.devtools.clouderrorreporting.v1beta1.ReportedErrorEvent";
|
|
22
|
+
function serviceName() {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
return (_b = (_a = process.env.K_SERVICE) != null ? _a : process.env.SERVICE_NAME) != null ? _b : "unknown";
|
|
25
|
+
}
|
|
26
|
+
function serviceVersion() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
return (_b = (_a = process.env.COMMIT_SHA) != null ? _a : process.env.K_REVISION) != null ? _b : "dev";
|
|
29
|
+
}
|
|
30
|
+
function formatUnknownError(err) {
|
|
31
|
+
var _a;
|
|
32
|
+
if (typeof err === "string") return err;
|
|
33
|
+
try {
|
|
34
|
+
return (_a = JSON.stringify(err)) != null ? _a : String(err);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
return String(err);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function buildReportedErrorEvent(err, context) {
|
|
40
|
+
var _a;
|
|
41
|
+
const error = err instanceof Error ? err : new Error(formatUnknownError(err));
|
|
42
|
+
const message = (_a = error.stack) != null ? _a : `${error.name}: ${error.message}`;
|
|
43
|
+
return __spreadValues({
|
|
44
|
+
severity: "ERROR",
|
|
45
|
+
"@type": REPORTED_ERROR_EVENT_TYPE,
|
|
46
|
+
message,
|
|
47
|
+
serviceContext: { service: serviceName(), version: serviceVersion() }
|
|
48
|
+
}, context && Object.keys(context).length > 0 ? { context } : {});
|
|
49
|
+
}
|
|
50
|
+
function reportError(err, context) {
|
|
51
|
+
try {
|
|
52
|
+
console.error(JSON.stringify(buildReportedErrorEvent(err, context)));
|
|
53
|
+
} catch (e) {
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
exports.buildReportedErrorEvent = buildReportedErrorEvent;
|
|
58
|
+
exports.reportError = reportError;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GCP Cloud Error Reporting integration — log-based, dependency-free.
|
|
3
|
+
*
|
|
4
|
+
* Cloud Error Reporting auto-ingests Cloud Logging entries shaped as a
|
|
5
|
+
* `ReportedErrorEvent`. On Firebase App Hosting (Cloud Run), single-line JSON
|
|
6
|
+
* written to stderr lands in Cloud Logging automatically — so emitting a
|
|
7
|
+
* correctly-shaped line is all it takes to surface a grouped, deduplicated
|
|
8
|
+
* error in the Error Reporting console. No SDK, no auth, no secrets (the
|
|
9
|
+
* `@google-cloud/error-reporting` library would add a gRPC client + cold-start
|
|
10
|
+
* weight + credential config for the same outcome on serverless).
|
|
11
|
+
*
|
|
12
|
+
* See https://cloud.google.com/error-reporting/docs/formatting-error-messages
|
|
13
|
+
*
|
|
14
|
+
* Grouping rules we satisfy:
|
|
15
|
+
* - `severity` must be ERROR or higher.
|
|
16
|
+
* - `message` must contain a full stack trace (that's what Error Reporting
|
|
17
|
+
* fingerprints on); we fall back to "name: message" when no stack exists,
|
|
18
|
+
* which still surfaces, just grouped less precisely.
|
|
19
|
+
* - `serviceContext.service` separates errors per deployable
|
|
20
|
+
* (core-api / web / public), so each app's errors are tracked apart.
|
|
21
|
+
*
|
|
22
|
+
* This module only ever *runs* from server code (core-api error-handler,
|
|
23
|
+
* Next instrumentation hooks, /api/client-error route handlers). It has no
|
|
24
|
+
* Node-only or heavy imports, so it stays safe to live in the shared package.
|
|
25
|
+
*/
|
|
26
|
+
interface ReportedErrorEvent {
|
|
27
|
+
severity: 'ERROR';
|
|
28
|
+
'@type': string;
|
|
29
|
+
message: string;
|
|
30
|
+
serviceContext: {
|
|
31
|
+
service: string;
|
|
32
|
+
version: string;
|
|
33
|
+
};
|
|
34
|
+
context?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Build the `ReportedErrorEvent` payload. Exported for unit testing; most
|
|
38
|
+
* callers want `reportError` instead.
|
|
39
|
+
*/
|
|
40
|
+
declare function buildReportedErrorEvent(err: unknown, context?: Record<string, unknown>): ReportedErrorEvent;
|
|
41
|
+
/**
|
|
42
|
+
* Report an error to GCP Error Reporting by emitting a single-line
|
|
43
|
+
* ReportedErrorEvent to stderr. Best-effort and total — a failure inside the
|
|
44
|
+
* reporter is swallowed so it can never mask the original error.
|
|
45
|
+
*/
|
|
46
|
+
declare function reportError(err: unknown, context?: Record<string, unknown>): void;
|
|
47
|
+
|
|
48
|
+
export { type ReportedErrorEvent, buildReportedErrorEvent, reportError };
|