palbase 0.0.0-stage → 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 +27 -0
- package/README.md +2 -2
- package/dist/ai/index.js +17 -0
- package/dist/backend/engine.js +2 -0
- package/dist/backend/env.js +1 -0
- package/dist/backend/index.js +12 -0
- package/dist/backend/stack.js +1 -0
- package/dist/backend/test.js +2 -0
- package/dist/chunks/3OGEBGYZ.js +20 -0
- package/dist/chunks/3VASGTIN.js +2 -0
- package/dist/chunks/3XT4L2XV.js +2 -0
- package/dist/chunks/45J7YXRB.js +2 -0
- package/dist/chunks/6FWCNTAM.js +2 -0
- package/dist/chunks/DAOLIUNZ.js +2 -0
- package/dist/chunks/E5Q4VTW4.js +2 -0
- package/dist/chunks/HKJU2FKE.js +2 -0
- package/dist/chunks/IKVOXHEE.js +2 -0
- package/dist/chunks/JAWWIVZH.js +2 -0
- package/dist/chunks/LYEFPLJZ.js +4 -0
- package/dist/chunks/QXUMLO7O.js +13 -0
- package/dist/chunks/UAY56IQR.js +6 -0
- package/dist/cli.js +815 -0
- package/dist/refuse/ai.js +2 -0
- package/dist/refuse/backend.js +2 -0
- package/dist/refuse/server.js +2 -0
- package/dist/server/index.js +2 -0
- package/dist/server/testing.js +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/palbe.js +2 -0
- package/dist/web/vite.js +3 -0
- package/package.json +107 -4
- package/types/ai/src/ai.d.ts +178 -0
- package/types/ai/src/index.d.ts +5 -0
- package/types/ai/src/partial.d.ts +1 -0
- package/types/ai/src/schema.d.ts +47 -0
- package/types/backend/src/bootstrap.d.ts +72 -0
- package/types/backend/src/cache.d.ts +32 -0
- package/types/backend/src/container.d.ts +49 -0
- package/types/backend/src/database.d.ts +148 -0
- package/types/backend/src/db-env.d.ts +4 -0
- package/types/backend/src/decorators.d.ts +293 -0
- package/types/backend/src/engine-db.d.ts +24 -0
- package/types/backend/src/engine-exports.d.ts +3 -0
- package/types/backend/src/engine.d.ts +124 -0
- package/types/backend/src/env.d.ts +27 -0
- package/types/backend/src/errors.d.ts +70 -0
- package/types/backend/src/i18n.d.ts +21 -0
- package/types/backend/src/index.d.ts +23 -0
- package/types/backend/src/openapi.d.ts +73 -0
- package/types/backend/src/platform-calls.d.ts +41 -0
- package/types/backend/src/requests.d.ts +81 -0
- package/types/backend/src/rooms.d.ts +168 -0
- package/types/backend/src/router.d.ts +22 -0
- package/types/backend/src/runtime.d.ts +56 -0
- package/types/backend/src/services.d.ts +262 -0
- package/types/backend/src/stack.d.ts +20 -0
- package/types/backend/src/strings-files.d.ts +3 -0
- package/types/backend/src/testing/index.d.ts +3 -0
- package/types/backend/src/testing/unit.d.ts +66 -0
- package/types/backend/src/upload.d.ts +125 -0
- package/types/backend/src/webhooks.d.ts +113 -0
- package/types/internal/src/event.d.ts +9 -0
- package/types/internal/src/modules/ai.d.ts +678 -0
- package/types/internal/src/modules/analytics.d.ts +1414 -0
- package/types/internal/src/modules/auth.d.ts +5660 -0
- package/types/internal/src/modules/cache.d.ts +158 -0
- package/types/internal/src/modules/events.d.ts +19 -0
- package/types/internal/src/modules/flags.d.ts +957 -0
- package/types/internal/src/modules/index.d.ts +13 -0
- package/types/internal/src/modules/machines.d.ts +1584 -0
- package/types/internal/src/modules/notify.d.ts +1450 -0
- package/types/internal/src/modules/purchases.d.ts +2944 -0
- package/types/internal/src/modules/realtime.d.ts +326 -0
- package/types/internal/src/modules/secrets.d.ts +275 -0
- package/types/internal/src/modules/storage.d.ts +691 -0
- package/types/internal/src/modules/stores.d.ts +1516 -0
- package/types/internal/src/retry.d.ts +14 -0
- package/types/internal/src/transport.d.ts +106 -0
- package/types/server/src/auth/dpop.d.ts +47 -0
- package/types/server/src/auth/jwt.d.ts +115 -0
- package/types/server/src/index.d.ts +9 -0
- package/types/server/src/pages.d.ts +4 -0
- package/types/server/src/purchases.d.ts +51 -0
- package/types/server/src/secrets-env.d.ts +22 -0
- package/types/server/src/server.d.ts +40 -0
- package/types/server/src/testing.d.ts +91 -0
- package/types/server/src/webhooks.d.ts +72 -0
- package/types/web/src/analytics.d.ts +87 -0
- package/types/web/src/auth.d.ts +155 -0
- package/types/web/src/backend-error.d.ts +38 -0
- package/types/web/src/backend-names.d.ts +25 -0
- package/types/web/src/backends.d.ts +84 -0
- package/types/web/src/client.d.ts +51 -0
- package/types/web/src/index.d.ts +11 -0
- package/types/web/src/palbe.d.ts +2 -0
- package/types/web/src/purchases.d.ts +73 -0
- package/types/web/src/rooms.d.ts +61 -0
- package/types/web/src/session.d.ts +91 -0
- package/types/web/src/socket.d.ts +87 -0
- package/types/web/src/vite.d.ts +49 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { type Reply, type Transport } from '../transport.js';
|
|
2
|
+
/**
|
|
3
|
+
* An entry's count.
|
|
4
|
+
*/
|
|
5
|
+
export type CacheCounter = {
|
|
6
|
+
/**
|
|
7
|
+
* The count after this increment.
|
|
8
|
+
*/
|
|
9
|
+
value: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* A read's answer.
|
|
13
|
+
*/
|
|
14
|
+
export type CacheEntry = {
|
|
15
|
+
/**
|
|
16
|
+
* The seconds the entry has left, rounded up; absent when there is none.
|
|
17
|
+
*/
|
|
18
|
+
expires_in?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the key holds an entry.
|
|
21
|
+
*/
|
|
22
|
+
found: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The JSON the entry was written with; absent when there is none. A written `null` is `found: true` with `value: null`.
|
|
25
|
+
*/
|
|
26
|
+
value?: unknown;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* A delete's answer.
|
|
30
|
+
*/
|
|
31
|
+
export type CacheEntryDeleted = {
|
|
32
|
+
/**
|
|
33
|
+
* Whether there was an entry.
|
|
34
|
+
*/
|
|
35
|
+
deleted: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* An entry's new value.
|
|
39
|
+
*/
|
|
40
|
+
export type CacheEntryWrite = {
|
|
41
|
+
/**
|
|
42
|
+
* The seconds the entry lasts, 1 to 2592000 (thirty days); thirty days without it.
|
|
43
|
+
*/
|
|
44
|
+
ttl?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Any JSON, 512 KiB at most as it is sent.
|
|
47
|
+
*/
|
|
48
|
+
value: unknown;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* A write's answer.
|
|
52
|
+
*/
|
|
53
|
+
export type CacheEntryWritten = {
|
|
54
|
+
/**
|
|
55
|
+
* How many of the project's own entries were dropped to keep it under its quota.
|
|
56
|
+
*/
|
|
57
|
+
evicted: number;
|
|
58
|
+
/**
|
|
59
|
+
* The seconds the entry lasts.
|
|
60
|
+
*/
|
|
61
|
+
expires_in: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* What a project's entries weigh.
|
|
65
|
+
*/
|
|
66
|
+
export type CacheUsage = {
|
|
67
|
+
/**
|
|
68
|
+
* What the live entries weigh together: each its value and its key three times, a quarter more, and 320 bytes.
|
|
69
|
+
*/
|
|
70
|
+
bytes: number;
|
|
71
|
+
/**
|
|
72
|
+
* How many live entries there are.
|
|
73
|
+
*/
|
|
74
|
+
entries: number;
|
|
75
|
+
/**
|
|
76
|
+
* The quota they stay under.
|
|
77
|
+
*/
|
|
78
|
+
limit_bytes: number;
|
|
79
|
+
};
|
|
80
|
+
export type ErrorResponse = {
|
|
81
|
+
/**
|
|
82
|
+
* Machine-readable error code (snake_case)
|
|
83
|
+
*/
|
|
84
|
+
error: string;
|
|
85
|
+
/**
|
|
86
|
+
* Human-readable explanation
|
|
87
|
+
*/
|
|
88
|
+
error_description: string;
|
|
89
|
+
/**
|
|
90
|
+
* Correlation ID for log/audit lookup
|
|
91
|
+
*/
|
|
92
|
+
request_id: string;
|
|
93
|
+
/**
|
|
94
|
+
* Seconds to wait before retrying; present on a refusal that ends with time.
|
|
95
|
+
*/
|
|
96
|
+
retry_after?: number;
|
|
97
|
+
/**
|
|
98
|
+
* HTTP status code (mirrors the response status)
|
|
99
|
+
*/
|
|
100
|
+
status: number;
|
|
101
|
+
};
|
|
102
|
+
/** Palbase Cache */
|
|
103
|
+
export declare function client(t: Transport): {
|
|
104
|
+
/**
|
|
105
|
+
* Read an entry
|
|
106
|
+
*
|
|
107
|
+
* Reads the entry of `key`. A key that holds nothing, or whose entry ran out, is not an error: the answer says `found: false`.
|
|
108
|
+
*/
|
|
109
|
+
getCacheEntry(input: {
|
|
110
|
+
query: {
|
|
111
|
+
key: string;
|
|
112
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
113
|
+
signal?: AbortSignal;
|
|
114
|
+
}): Promise<Reply<200, CacheEntry>>;
|
|
115
|
+
/**
|
|
116
|
+
* Write an entry
|
|
117
|
+
*
|
|
118
|
+
* Writes the value under `key` for `ttl` seconds (thirty days without one, and at most), replacing what was there. A value is any JSON, 512 KiB at most. Writing the same value again changes nothing but the time left, so the call is safe to send again. When the project's entries would pass its quota the ones nearest their end are dropped first (`evicted`).
|
|
119
|
+
*/
|
|
120
|
+
putCacheEntry(input: {
|
|
121
|
+
query: {
|
|
122
|
+
key: string;
|
|
123
|
+
};
|
|
124
|
+
body: CacheEntryWrite; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
125
|
+
signal?: AbortSignal;
|
|
126
|
+
}): Promise<Reply<200, CacheEntryWritten>>;
|
|
127
|
+
/**
|
|
128
|
+
* Delete an entry
|
|
129
|
+
*
|
|
130
|
+
* Deletes the entry of `key`. Deleting what is not there is not an error (`deleted: false`), so the call is safe to send again.
|
|
131
|
+
*/
|
|
132
|
+
deleteCacheEntry(input: {
|
|
133
|
+
query: {
|
|
134
|
+
key: string;
|
|
135
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
136
|
+
signal?: AbortSignal;
|
|
137
|
+
}): Promise<Reply<200, CacheEntryDeleted>>;
|
|
138
|
+
/**
|
|
139
|
+
* Count up an entry
|
|
140
|
+
*
|
|
141
|
+
* Adds one to the entry's count and answers the new count, atomically: two callers never get the same number. An entry that is not there, or holds something that is not a whole number, counts from zero. A count keeps the time it had left; a new one lasts thirty days. A count stops short of sixteen digits. Sent again, it counts again — and when the cache could not be reached (503) the count may already have been taken.
|
|
142
|
+
*/
|
|
143
|
+
incrementCacheEntry(input: {
|
|
144
|
+
query: {
|
|
145
|
+
key: string;
|
|
146
|
+
}; /** Stops the call: the request in flight, a wait before a retry, a proof-of-work being solved. */
|
|
147
|
+
signal?: AbortSignal;
|
|
148
|
+
}): Promise<Reply<200, CacheCounter>>;
|
|
149
|
+
/**
|
|
150
|
+
* Read the cache's usage
|
|
151
|
+
*
|
|
152
|
+
* What the project's live entries weigh together, the quota they stay under, and how many there are.
|
|
153
|
+
*/
|
|
154
|
+
getCacheUsage(input?: {
|
|
155
|
+
signal?: AbortSignal;
|
|
156
|
+
}): Promise<Reply<200, CacheUsage>>;
|
|
157
|
+
};
|
|
158
|
+
export type Client = ReturnType<typeof client>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WebhookEvent } from '../event.js';
|
|
2
|
+
import type { Events as AiEvents } from './ai.js';
|
|
3
|
+
import type { Events as PurchasesEvents } from './purchases.js';
|
|
4
|
+
import type { Events as StorageEvents } from './storage.js';
|
|
5
|
+
import type { Events as StoresEvents } from './stores.js';
|
|
6
|
+
/** Every event the modules' contracts say they send the project's webhooks (x-palbase-events), by type: its payload, the event's data. */
|
|
7
|
+
export interface PlatformEvents extends AiEvents, PurchasesEvents, StorageEvents, StoresEvents {
|
|
8
|
+
}
|
|
9
|
+
/** A platform event's type: one a module's contract declares. */
|
|
10
|
+
export type EventType = keyof PlatformEvents;
|
|
11
|
+
/** Every platform event's type, as the contracts declare them. */
|
|
12
|
+
export declare const EVENT_TYPES: readonly ["ai.response.completed", "ai.response.failed", "file.deleted", "file.moved", "file.uploaded", "purchases.catalog.applied", "purchases.catalog.changed", "purchases.credits.depleted", "purchases.credits.low", "purchases.customer.changed", "purchases.customer.erased", "purchases.customer.merged", "purchases.entitlement.changed", "purchases.ownership.transferred", "purchases.purchase.completed", "purchases.quota.exhausted", "purchases.quota.threshold", "purchases.refund.changed", "purchases.store.changed", "purchases.subscription.changed", "stores.action.changed", "stores.app.changed", "stores.apple.changed", "stores.delivery.changed", "stores.delivery.requested", "stores.group.changed", "stores.package.changed"];
|
|
13
|
+
/**
|
|
14
|
+
* A platform event as delivered: one member per type the contracts declare,
|
|
15
|
+
* its data that type's payload, so a switch on its type narrows it. An
|
|
16
|
+
* event of a type none of them declares (one a newer platform sends) is no
|
|
17
|
+
* member: at run time it reaches the switch's default, which takes it.
|
|
18
|
+
*/
|
|
19
|
+
export type PalbaseEvent = WebhookEvent<PlatformEvents["ai.response.completed"], "ai.response.completed"> | WebhookEvent<PlatformEvents["ai.response.failed"], "ai.response.failed"> | WebhookEvent<PlatformEvents["file.deleted"], "file.deleted"> | WebhookEvent<PlatformEvents["file.moved"], "file.moved"> | WebhookEvent<PlatformEvents["file.uploaded"], "file.uploaded"> | WebhookEvent<PlatformEvents["purchases.catalog.applied"], "purchases.catalog.applied"> | WebhookEvent<PlatformEvents["purchases.catalog.changed"], "purchases.catalog.changed"> | WebhookEvent<PlatformEvents["purchases.credits.depleted"], "purchases.credits.depleted"> | WebhookEvent<PlatformEvents["purchases.credits.low"], "purchases.credits.low"> | WebhookEvent<PlatformEvents["purchases.customer.changed"], "purchases.customer.changed"> | WebhookEvent<PlatformEvents["purchases.customer.erased"], "purchases.customer.erased"> | WebhookEvent<PlatformEvents["purchases.customer.merged"], "purchases.customer.merged"> | WebhookEvent<PlatformEvents["purchases.entitlement.changed"], "purchases.entitlement.changed"> | WebhookEvent<PlatformEvents["purchases.ownership.transferred"], "purchases.ownership.transferred"> | WebhookEvent<PlatformEvents["purchases.purchase.completed"], "purchases.purchase.completed"> | WebhookEvent<PlatformEvents["purchases.quota.exhausted"], "purchases.quota.exhausted"> | WebhookEvent<PlatformEvents["purchases.quota.threshold"], "purchases.quota.threshold"> | WebhookEvent<PlatformEvents["purchases.refund.changed"], "purchases.refund.changed"> | WebhookEvent<PlatformEvents["purchases.store.changed"], "purchases.store.changed"> | WebhookEvent<PlatformEvents["purchases.subscription.changed"], "purchases.subscription.changed"> | WebhookEvent<PlatformEvents["stores.action.changed"], "stores.action.changed"> | WebhookEvent<PlatformEvents["stores.app.changed"], "stores.app.changed"> | WebhookEvent<PlatformEvents["stores.apple.changed"], "stores.apple.changed"> | WebhookEvent<PlatformEvents["stores.delivery.changed"], "stores.delivery.changed"> | WebhookEvent<PlatformEvents["stores.delivery.requested"], "stores.delivery.requested"> | WebhookEvent<PlatformEvents["stores.group.changed"], "stores.group.changed"> | WebhookEvent<PlatformEvents["stores.package.changed"], "stores.package.changed">;
|