diff --git a/packages/pl-api/lib/entities/filter-result.ts b/packages/pl-api/lib/entities/filter-result.ts index 9b8c37eb1..f5b60a130 100644 --- a/packages/pl-api/lib/entities/filter-result.ts +++ b/packages/pl-api/lib/entities/filter-result.ts @@ -1,6 +1,8 @@ import * as v from 'valibot'; -import { filterSchema } from './filter'; +import { baseFilterSchema } from './filter'; + +const filterSchema = v.omit(baseFilterSchema, ['keywords', 'statuses']); /** * @category Schemas diff --git a/packages/pl-api/lib/entities/filter.ts b/packages/pl-api/lib/entities/filter.ts index 9be775503..7314ed755 100644 --- a/packages/pl-api/lib/entities/filter.ts +++ b/packages/pl-api/lib/entities/filter.ts @@ -21,6 +21,16 @@ const filterStatusSchema = v.object({ status_id: v.string(), }); +const baseFilterSchema = v.object({ + id: v.string(), + title: v.string(), + context: v.array(v.picklist(['home', 'notifications', 'public', 'thread', 'account'])), + expires_at: v.fallback(v.nullable(datetimeSchema), null), + filter_action: v.fallback(v.picklist(['warn', 'hide', 'blur']), 'warn'), + keywords: filteredArray(filterKeywordSchema), + statuses: filteredArray(filterStatusSchema), +}); + /** * @category Schemas * @see {@link https://docs.joinmastodon.org/entities/Filter/} @@ -42,15 +52,7 @@ const filterSchema = v.pipe( } return filter; }), - v.object({ - id: v.string(), - title: v.string(), - context: v.array(v.picklist(['home', 'notifications', 'public', 'thread', 'account'])), - expires_at: v.fallback(v.nullable(datetimeSchema), null), - filter_action: v.fallback(v.picklist(['warn', 'hide', 'blur']), 'warn'), - keywords: v.optional(filteredArray(filterKeywordSchema), undefined), - statuses: v.optional(filteredArray(filterStatusSchema), undefined), - }), + baseFilterSchema, ); /** @@ -58,4 +60,4 @@ const filterSchema = v.pipe( */ type Filter = v.InferOutput; -export { filterKeywordSchema, filterStatusSchema, filterSchema, type Filter }; +export { filterKeywordSchema, filterStatusSchema, baseFilterSchema, filterSchema, type Filter }; diff --git a/packages/pl-api/lib/entities/privacy-policy.ts b/packages/pl-api/lib/entities/privacy-policy.ts new file mode 100644 index 000000000..304260ac6 --- /dev/null +++ b/packages/pl-api/lib/entities/privacy-policy.ts @@ -0,0 +1,19 @@ +import * as v from 'valibot'; + +import { datetimeSchema } from './utils'; + +/** + * @category Schemas + * @see {@link https://docs.joinmastodon.org/entities/PrivacyPolicy/} + */ +const privacyPolicySchema = v.object({ + updated_at: datetimeSchema, + content: v.string(), +}); + +/** + * @category Entity types + */ +type PrivacyPolicy = v.InferOutput; + +export { privacyPolicySchema, type PrivacyPolicy }; diff --git a/packages/pl-api/lib/entities/terms-of-service.ts b/packages/pl-api/lib/entities/terms-of-service.ts new file mode 100644 index 000000000..94ec03684 --- /dev/null +++ b/packages/pl-api/lib/entities/terms-of-service.ts @@ -0,0 +1,21 @@ +import * as v from 'valibot'; + +import { dateSchema } from './utils'; + +/** + * @category Schemas + * @see {@link https://docs.joinmastodon.org/entities/TermfsOfService/} + */ +const termfsOfServiceSchema = v.object({ + effective_date: dateSchema, + effective: v.boolean(), + content: v.string(), + succeeded_by: v.fallback(v.nullable(dateSchema), null), +}); + +/** + * @category Entity types + */ +type TermfsOfService = v.InferOutput; + +export { termfsOfServiceSchema, type TermfsOfService }; diff --git a/packages/pl-api/package.json b/packages/pl-api/package.json index 832163e1c..b071fe211 100644 --- a/packages/pl-api/package.json +++ b/packages/pl-api/package.json @@ -1,6 +1,6 @@ { "name": "pl-api", - "version": "1.0.0-rc.68", + "version": "1.0.0-rc.69", "type": "module", "homepage": "https://github.com/mkljczk/pl-fe/tree/develop/packages/pl-api", "repository": { diff --git a/packages/pl-fe/package.json b/packages/pl-fe/package.json index ec1fb103e..cddf6b525 100644 --- a/packages/pl-fe/package.json +++ b/packages/pl-fe/package.json @@ -105,7 +105,7 @@ "multiselect-react-dropdown": "^2.0.25", "mutative": "^1.1.0", "path-browserify": "^1.0.1", - "pl-api": "^1.0.0-rc.68", + "pl-api": "^1.0.0-rc.69", "postcss": "^8.5.3", "process": "^0.11.10", "punycode": "^2.1.1", diff --git a/packages/pl-fe/src/reducers/instance.ts b/packages/pl-fe/src/reducers/instance.ts index 9d4475dc5..a6015eed8 100644 --- a/packages/pl-fe/src/reducers/instance.ts +++ b/packages/pl-fe/src/reducers/instance.ts @@ -37,6 +37,7 @@ const importConfigs = (state: State, configs: PleromaConfig['configs']) => { const approvalRequired = getConfigValue(value, ':account_approval_required') as boolean | undefined; state.registrations = { + ...state.registrations, enabled: registrationsOpen ?? state.registrations.enabled, approval_required: approvalRequired ?? state.registrations.approval_required, }; diff --git a/packages/pl-fe/yarn.lock b/packages/pl-fe/yarn.lock index 1546e44a4..9dc5bb2c5 100644 --- a/packages/pl-fe/yarn.lock +++ b/packages/pl-fe/yarn.lock @@ -6875,10 +6875,10 @@ pkg-dir@^4.1.0: dependencies: find-up "^4.0.0" -pl-api@^1.0.0-rc.68: - version "1.0.0-rc.68" - resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.68.tgz#c334e710e349403bebcd89e42dbc87efc0b4d612" - integrity sha512-CMSlxTsKL965J03Y4OfwQq/uV4hSh/daBcsVw2Tzx0KTtR/nnUE+hwfw0E0PypMFxZojPuZEGbxpuoT1JXgPSQ== +pl-api@^1.0.0-rc.69: + version "1.0.0-rc.69" + resolved "https://registry.yarnpkg.com/pl-api/-/pl-api-1.0.0-rc.69.tgz#a271fcd8963e1df106bee0e081b3d4f728094259" + integrity sha512-9EVEiOE5hNBLac+0C+Z/daAxhi0IRjR0arY1m9NIvnvUfUVIbJNSSWTdVtFyd2e0CqOhFG/fiCxNZRR/qqyuNg== dependencies: blurhash "^2.0.5" http-link-header "^1.1.3"