@openupstream/sdk 0.5.0 → 0.10.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/dist/model.js CHANGED
@@ -4,8 +4,40 @@
4
4
  *
5
5
  * Ids are UUIDs, timestamps RFC 3339 strings.
6
6
  */
7
- /** Compute Sites, where Databases, Services and Jobs run. Both are in Germany. */
8
- export const COMPUTE_SITES = ['hetzner-fsn1', 'ovh-lim'];
7
+ export const SITE_ID = /^[A-Za-z0-9]([-A-Za-z0-9_.]{0,61}[A-Za-z0-9])?$/;
8
+ /**
9
+ * What can be wrong with the nodes' Site labels (ADR-0008): the rules the
10
+ * install checks, which the control plane checks again while the cluster
11
+ * runs. Each has an alert of its own.
12
+ */
13
+ export const SITE_PROBLEMS = [
14
+ 'node-without-site',
15
+ 'node-neither-compute-nor-quorum',
16
+ 'node-compute-and-quorum',
17
+ 'site-mixed-compute',
18
+ 'site-mixed-default',
19
+ 'default-site-missing',
20
+ 'default-site-not-unique',
21
+ 'default-site-not-compute',
22
+ 'compute-sites-below-two',
23
+ 'sites-below-three',
24
+ ];
25
+ /**
26
+ * What a Member may do in the whole Account (decision 138): `owner`
27
+ * everything, the Account's Members included; `developer` every Project and
28
+ * everything in it.
29
+ */
30
+ export const MEMBER_ROLES = ['owner', 'developer'];
31
+ /**
32
+ * What an Account token may do in the whole Account (decision 144):
33
+ * `developer`, as a Member with that role; never `owner`, so a token
34
+ * cannot manage the Account.
35
+ */
36
+ export const ACCOUNT_TOKEN_ROLES = ['developer'];
37
+ /** How an Account token's secret starts; `oup` and the SDK send it like an API key (`OUP_API_KEY`). */
38
+ export const ACCOUNT_TOKEN_PREFIX = 'oup_tok_';
39
+ /** An Account token expires at most this many days after it is created or rolled. */
40
+ export const ACCOUNT_TOKEN_MAX_DAYS = 365;
9
41
  /** Postgres always runs with at least this much memory. */
10
42
  export const DATABASE_MIN_MEMORY_MB = 256;
11
43
  /**
@@ -42,6 +74,40 @@ export const SERVICE_LIMITS = {
42
74
  minCpuMillicores: 50,
43
75
  maxCpuMillicores: 8000,
44
76
  };
77
+ /**
78
+ * Limits of what a Service's or Job's definition names for its containers'
79
+ * environment (decision 170). The values of the Secrets a definition names
80
+ * share one Kubernetes Secret, hence their total.
81
+ */
82
+ export const ENVIRONMENT_LIMITS = {
83
+ maxSecrets: 256,
84
+ maxVariables: 256,
85
+ maxVariableValueBytes: 32 * 1024,
86
+ maxVariablesTotalBytes: 256 * 1024,
87
+ maxNamedSecretsTotalBytes: 512 * 1024,
88
+ };
89
+ /** Names starting with this are the platform's own variables and cannot be a Secret's or a Variable's in a definition. */
90
+ export const RESERVED_ENVIRONMENT_PREFIX = 'OUP_';
91
+ /**
92
+ * Read live from its Deployment: `deploying` until the first replica is
93
+ * up and while a new version rolls out, `running` with every replica
94
+ * available, `degraded` with some, `unknown` when Kubernetes cannot be asked.
95
+ * Before a rollout of a Service with a pre-deploy Job: `pre-deploy` while
96
+ * that Job's run is waited for, `pre-deploy-failed` when it failed, and
97
+ * the Service then keeps running what it ran before.
98
+ */
99
+ /**
100
+ * How a Service or Job reaches a Database it names (decision 173): `own`,
101
+ * as a Postgres role of its own (`svc_<name>`, `job_<name>`) that can
102
+ * connect and nothing else until the Database's owner grants it rights in
103
+ * SQL; `owner`, as the role that owns the Database, for what changes the
104
+ * schema and gives those rights.
105
+ */
106
+ export const DEFINITION_DATABASE_ACCESS = ['own', 'owner'];
107
+ /** A Service or Job names at most this many Databases. */
108
+ export const MAX_NAMED_DATABASES = 16;
109
+ /** The longest name of a Service or Job that can have a role of its own: Postgres's names end at 63, and the role's has a prefix of 4. */
110
+ export const MAX_NAME_WITH_OWN_ROLE = 59;
45
111
  /** Limits of a Job, checked by the API; memory and CPU as for a Service. */
46
112
  export const JOB_LIMITS = {
47
113
  minMemoryMb: SERVICE_LIMITS.minMemoryMb,
@@ -69,12 +135,38 @@ export const LOG_LIMITS = {
69
135
  /** A Secret's name is an environment variable name (the schema checks the same). */
70
136
  export const SECRET_NAME = /^[A-Za-z_][A-Za-z0-9_]{0,254}$/;
71
137
  /**
72
- * At most this many bytes (UTF-8) per value, and all of a Project's values
73
- * together at most SECRETS_MAX_TOTAL_BYTES: they go into one Kubernetes
74
- * Secret (1 MiB at most) and into every container's environment.
138
+ * At most this many bytes (UTF-8) per value. The values one Service or Job
139
+ * names together are limited by ENVIRONMENT_LIMITS.maxNamedSecretsTotalBytes.
75
140
  */
76
141
  export const SECRET_VALUE_MAX_BYTES = 64 * 1024;
77
- export const SECRETS_MAX_TOTAL_BYTES = 512 * 1024;
142
+ /** At most this many Secrets per Project: what bounds a Project's Secrets, since no limit is on their size together. */
143
+ export const SECRETS_MAX_PER_PROJECT = 1000;
144
+ /** Limits of Keys (ARCHITECTURE.md, decision 167). */
145
+ export const KEY_LIMITS = {
146
+ /** Keys per Project, those pending deletion included. */
147
+ maxPerProject: 20,
148
+ /** How long a deleted Key refuses every call and can still be restored, before it is erased. */
149
+ deletionDays: 7,
150
+ /** Versions of one Key: every one is kept for the Key's life, so `rotate` is refused above this. */
151
+ maxVersions: 1000,
152
+ };
153
+ /** Limits of one call of the key API (decision 167). */
154
+ export const KEY_CALL_LIMITS = {
155
+ /** A plaintext, decoded: larger data is encrypted with a key of the customer's own, which is encrypted with the Key. */
156
+ maxPlaintextBytes: 4096,
157
+ maxContextEntries: 16,
158
+ /** A context's names and values together, as UTF-8. */
159
+ maxContextBytes: 1024,
160
+ /** A request's body. */
161
+ maxBodyBytes: 16 * 1024,
162
+ /** How long a call's record is kept (decision 169). */
163
+ retentionDays: 30,
164
+ /** Records one listing returns at most, and by default. */
165
+ maxListed: 1000,
166
+ defaultListed: 100,
167
+ };
168
+ /** What a grant on a Key allows. Not ordered: `encrypt` does not include `decrypt`, nor the reverse. */
169
+ export const KEY_ACCESS = ['encrypt', 'decrypt', 'both'];
78
170
  /** Where the TXT ownership proof for `hostname` has to be published. */
79
171
  export function txtRecordName(hostname) {
80
172
  return `_openupstream.${hostname}`;
package/d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I;IACvB,iBAAiB,EAAE,EAAE;IACrB,uDAAuD;IACvD,eAAe,EAAE,IAAI;IACrB,wBAAwB;IACxB,YAAY,EAAE,EAAE,GAAG,IAAI;IACvB,uDAAuD;IACvD,aAAa,EAAE,EAAE;IACjB,2DAA2D;IAC3D,SAAS,EAAE,IAAI;IACf,aAAa,EAAE,GAAG;CACZ,CAAC;AA8BX,wGAAwG;AACxG,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,MAAM,CAAU,CAAC;AAyFlE,wEAAwE;AACxE,MAAM,UAAU,aAAa,CAAC,QAAgB;IAC1C,OAAO,iBAAiB,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,uFAAuF,CAAC;AAahH,2GAA2G;AAC3G,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAsC1D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAU,CAAC;AAmEhF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,WAAW,CAAU,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openupstream/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.10.0",
4
4
  "description": "TypeScript client for the openupstream API",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -17,6 +17,10 @@
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
19
19
  "import": "./dist/index.js"
20
+ },
21
+ "./keys": {
22
+ "types": "./dist/keys.d.ts",
23
+ "import": "./dist/keys.js"
20
24
  }
21
25
  },
22
26
  "files": [