@atproto/api 0.5.4 → 0.6.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/README.md CHANGED
@@ -222,14 +222,22 @@ function getOpts() {
222
222
  // is adult content allowed?
223
223
  adultContentEnabled: true,
224
224
 
225
- // the user's labeler settings
226
- labelerSettings: [
225
+ // the global label settings (used on self-labels)
226
+ labels: {
227
+ porn: 'hide',
228
+ sexual: 'warn',
229
+ nudity: 'ignore',
230
+ // ...
231
+ },
232
+
233
+ // the per-labeler settings
234
+ labelers: [
227
235
  {
228
236
  labeler: {
229
237
  did: '...',
230
238
  displayName: 'My mod service'
231
239
  },
232
- settings: {
240
+ labels: {
233
241
  porn: 'hide',
234
242
  sexual: 'warn',
235
243
  nudity: 'ignore',
@@ -1315,6 +1315,33 @@ export declare const schemaDict: {
1315
1315
  };
1316
1316
  };
1317
1317
  };
1318
+ selfLabels: {
1319
+ type: string;
1320
+ description: string;
1321
+ required: string[];
1322
+ properties: {
1323
+ values: {
1324
+ type: string;
1325
+ items: {
1326
+ type: string;
1327
+ ref: string;
1328
+ };
1329
+ maxLength: number;
1330
+ };
1331
+ };
1332
+ };
1333
+ selfLabel: {
1334
+ type: string;
1335
+ description: string;
1336
+ required: string[];
1337
+ properties: {
1338
+ val: {
1339
+ type: string;
1340
+ maxLength: number;
1341
+ description: string;
1342
+ };
1343
+ };
1344
+ };
1318
1345
  };
1319
1346
  };
1320
1347
  ComAtprotoLabelQueryLabels: {
@@ -3653,6 +3680,10 @@ export declare const schemaDict: {
3653
3680
  accept: string[];
3654
3681
  maxSize: number;
3655
3682
  };
3683
+ labels: {
3684
+ type: string;
3685
+ refs: string[];
3686
+ };
3656
3687
  };
3657
3688
  };
3658
3689
  };
@@ -4360,6 +4391,10 @@ export declare const schemaDict: {
4360
4391
  accept: string[];
4361
4392
  maxSize: number;
4362
4393
  };
4394
+ labels: {
4395
+ type: string;
4396
+ refs: string[];
4397
+ };
4363
4398
  createdAt: {
4364
4399
  type: string;
4365
4400
  format: string;
@@ -4441,6 +4476,11 @@ export declare const schemaDict: {
4441
4476
  cursor: {
4442
4477
  type: string;
4443
4478
  };
4479
+ filter: {
4480
+ type: string;
4481
+ knownValues: string[];
4482
+ default: string;
4483
+ };
4444
4484
  };
4445
4485
  };
4446
4486
  output: {
@@ -4988,6 +5028,10 @@ export declare const schemaDict: {
4988
5028
  format: string;
4989
5029
  };
4990
5030
  };
5031
+ labels: {
5032
+ type: string;
5033
+ refs: string[];
5034
+ };
4991
5035
  createdAt: {
4992
5036
  type: string;
4993
5037
  format: string;
@@ -5605,6 +5649,10 @@ export declare const schemaDict: {
5605
5649
  accept: string[];
5606
5650
  maxSize: number;
5607
5651
  };
5652
+ labels: {
5653
+ type: string;
5654
+ refs: string[];
5655
+ };
5608
5656
  createdAt: {
5609
5657
  type: string;
5610
5658
  format: string;
@@ -1,9 +1,14 @@
1
1
  import { ValidationResult, BlobRef } from '@atproto/lexicon';
2
+ import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs';
2
3
  export interface Record {
3
4
  displayName?: string;
4
5
  description?: string;
5
6
  avatar?: BlobRef;
6
7
  banner?: BlobRef;
8
+ labels?: ComAtprotoLabelDefs.SelfLabels | {
9
+ $type: string;
10
+ [k: string]: unknown;
11
+ };
7
12
  [k: string]: unknown;
8
13
  }
9
14
  export declare function isRecord(v: unknown): v is Record;
@@ -1,11 +1,16 @@
1
1
  import { ValidationResult, BlobRef } from '@atproto/lexicon';
2
2
  import * as AppBskyRichtextFacet from '../richtext/facet';
3
+ import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs';
3
4
  export interface Record {
4
5
  did: string;
5
6
  displayName: string;
6
7
  description?: string;
7
8
  descriptionFacets?: AppBskyRichtextFacet.Main[];
8
9
  avatar?: BlobRef;
10
+ labels?: ComAtprotoLabelDefs.SelfLabels | {
11
+ $type: string;
12
+ [k: string]: unknown;
13
+ };
9
14
  createdAt: string;
10
15
  [k: string]: unknown;
11
16
  }
@@ -4,6 +4,7 @@ export interface QueryParams {
4
4
  actor: string;
5
5
  limit?: number;
6
6
  cursor?: string;
7
+ filter?: 'posts_with_replies' | 'posts_no_replies' | 'posts_with_media' | (string & {});
7
8
  }
8
9
  export declare type InputSchema = undefined;
9
10
  export interface OutputSchema {
@@ -4,6 +4,7 @@ import * as AppBskyEmbedImages from '../embed/images';
4
4
  import * as AppBskyEmbedExternal from '../embed/external';
5
5
  import * as AppBskyEmbedRecord from '../embed/record';
6
6
  import * as AppBskyEmbedRecordWithMedia from '../embed/recordWithMedia';
7
+ import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs';
7
8
  import * as ComAtprotoRepoStrongRef from '../../../com/atproto/repo/strongRef';
8
9
  export interface Record {
9
10
  text: string;
@@ -15,6 +16,10 @@ export interface Record {
15
16
  [k: string]: unknown;
16
17
  };
17
18
  langs?: string[];
19
+ labels?: ComAtprotoLabelDefs.SelfLabels | {
20
+ $type: string;
21
+ [k: string]: unknown;
22
+ };
18
23
  createdAt: string;
19
24
  [k: string]: unknown;
20
25
  }
@@ -1,12 +1,17 @@
1
1
  import { ValidationResult, BlobRef } from '@atproto/lexicon';
2
2
  import * as AppBskyGraphDefs from './defs';
3
3
  import * as AppBskyRichtextFacet from '../richtext/facet';
4
+ import * as ComAtprotoLabelDefs from '../../../com/atproto/label/defs';
4
5
  export interface Record {
5
6
  purpose: AppBskyGraphDefs.ListPurpose;
6
7
  name: string;
7
8
  description?: string;
8
9
  descriptionFacets?: AppBskyRichtextFacet.Main[];
9
10
  avatar?: BlobRef;
11
+ labels?: ComAtprotoLabelDefs.SelfLabels | {
12
+ $type: string;
13
+ [k: string]: unknown;
14
+ };
10
15
  createdAt: string;
11
16
  [k: string]: unknown;
12
17
  }
@@ -10,3 +10,15 @@ export interface Label {
10
10
  }
11
11
  export declare function isLabel(v: unknown): v is Label;
12
12
  export declare function validateLabel(v: unknown): ValidationResult;
13
+ export interface SelfLabels {
14
+ values: SelfLabel[];
15
+ [k: string]: unknown;
16
+ }
17
+ export declare function isSelfLabels(v: unknown): v is SelfLabels;
18
+ export declare function validateSelfLabels(v: unknown): ValidationResult;
19
+ export interface SelfLabel {
20
+ val: string;
21
+ [k: string]: unknown;
22
+ }
23
+ export declare function isSelfLabel(v: unknown): v is SelfLabel;
24
+ export declare function validateSelfLabel(v: unknown): ValidationResult;
package/dist/index.js CHANGED
@@ -17131,6 +17131,33 @@ var schemaDict = {
17131
17131
  description: "timestamp when this label was created"
17132
17132
  }
17133
17133
  }
17134
+ },
17135
+ selfLabels: {
17136
+ type: "object",
17137
+ description: "Metadata tags on an atproto record, published by the author within the record.",
17138
+ required: ["values"],
17139
+ properties: {
17140
+ values: {
17141
+ type: "array",
17142
+ items: {
17143
+ type: "ref",
17144
+ ref: "lex:com.atproto.label.defs#selfLabel"
17145
+ },
17146
+ maxLength: 10
17147
+ }
17148
+ }
17149
+ },
17150
+ selfLabel: {
17151
+ type: "object",
17152
+ description: "Metadata tag on an atproto record, published by the author within the record. Note -- schemas should use #selfLabels, not #selfLabel.",
17153
+ required: ["val"],
17154
+ properties: {
17155
+ val: {
17156
+ type: "string",
17157
+ maxLength: 128,
17158
+ description: "the short string name of the value or type of this label"
17159
+ }
17160
+ }
17134
17161
  }
17135
17162
  }
17136
17163
  },
@@ -19592,6 +19619,10 @@ var schemaDict = {
19592
19619
  type: "blob",
19593
19620
  accept: ["image/png", "image/jpeg"],
19594
19621
  maxSize: 1e6
19622
+ },
19623
+ labels: {
19624
+ type: "union",
19625
+ refs: ["lex:com.atproto.label.defs#selfLabels"]
19595
19626
  }
19596
19627
  }
19597
19628
  }
@@ -20335,6 +20366,10 @@ var schemaDict = {
20335
20366
  accept: ["image/png", "image/jpeg"],
20336
20367
  maxSize: 1e6
20337
20368
  },
20369
+ labels: {
20370
+ type: "union",
20371
+ refs: ["lex:com.atproto.label.defs#selfLabels"]
20372
+ },
20338
20373
  createdAt: {
20339
20374
  type: "string",
20340
20375
  format: "datetime"
@@ -20415,6 +20450,15 @@ var schemaDict = {
20415
20450
  },
20416
20451
  cursor: {
20417
20452
  type: "string"
20453
+ },
20454
+ filter: {
20455
+ type: "string",
20456
+ knownValues: [
20457
+ "posts_with_replies",
20458
+ "posts_no_replies",
20459
+ "posts_with_media"
20460
+ ],
20461
+ default: "posts_with_replies"
20418
20462
  }
20419
20463
  }
20420
20464
  },
@@ -20983,6 +21027,10 @@ var schemaDict = {
20983
21027
  format: "language"
20984
21028
  }
20985
21029
  },
21030
+ labels: {
21031
+ type: "union",
21032
+ refs: ["lex:com.atproto.label.defs#selfLabels"]
21033
+ },
20986
21034
  createdAt: {
20987
21035
  type: "string",
20988
21036
  format: "datetime"
@@ -21600,6 +21648,10 @@ var schemaDict = {
21600
21648
  accept: ["image/png", "image/jpeg"],
21601
21649
  maxSize: 1e6
21602
21650
  },
21651
+ labels: {
21652
+ type: "union",
21653
+ refs: ["lex:com.atproto.label.defs#selfLabels"]
21654
+ },
21603
21655
  createdAt: {
21604
21656
  type: "string",
21605
21657
  format: "datetime"
@@ -23723,7 +23775,11 @@ function validateVideoDetails(v) {
23723
23775
  var defs_exports2 = {};
23724
23776
  __export(defs_exports2, {
23725
23777
  isLabel: () => isLabel,
23726
- validateLabel: () => validateLabel
23778
+ isSelfLabel: () => isSelfLabel,
23779
+ isSelfLabels: () => isSelfLabels,
23780
+ validateLabel: () => validateLabel,
23781
+ validateSelfLabel: () => validateSelfLabel,
23782
+ validateSelfLabels: () => validateSelfLabels
23727
23783
  });
23728
23784
  function isLabel(v) {
23729
23785
  return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.label.defs#label";
@@ -23731,6 +23787,18 @@ function isLabel(v) {
23731
23787
  function validateLabel(v) {
23732
23788
  return lexicons.validate("com.atproto.label.defs#label", v);
23733
23789
  }
23790
+ function isSelfLabels(v) {
23791
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.label.defs#selfLabels";
23792
+ }
23793
+ function validateSelfLabels(v) {
23794
+ return lexicons.validate("com.atproto.label.defs#selfLabels", v);
23795
+ }
23796
+ function isSelfLabel(v) {
23797
+ return isObj2(v) && hasProp2(v, "$type") && v.$type === "com.atproto.label.defs#selfLabel";
23798
+ }
23799
+ function validateSelfLabel(v) {
23800
+ return lexicons.validate("com.atproto.label.defs#selfLabel", v);
23801
+ }
23734
23802
 
23735
23803
  // src/client/types/com/atproto/label/subscribeLabels.ts
23736
23804
  var subscribeLabels_exports = {};
@@ -28136,17 +28204,17 @@ var ModerationCauseAccumulator = class {
28136
28204
  if (!labelDef) {
28137
28205
  return;
28138
28206
  }
28139
- const labelerSettings = opts.labelerSettings[0];
28140
- if (!labelerSettings) {
28141
- return;
28142
- }
28207
+ const isSelf = label.src === this.did;
28208
+ const labeler = isSelf ? void 0 : opts.labelers.find((s) => s.labeler.did === label.src);
28143
28209
  let labelPref = "ignore";
28144
28210
  if (!labelDef.configurable) {
28145
28211
  labelPref = labelDef.preferences[0];
28146
28212
  } else if (labelDef.flags.includes("adult") && !opts.adultContentEnabled) {
28147
28213
  labelPref = "hide";
28148
- } else if (labelerSettings.settings[label.val]) {
28149
- labelPref = labelerSettings.settings[label.val];
28214
+ } else if (labeler?.labels[label.val]) {
28215
+ labelPref = labeler.labels[label.val];
28216
+ } else if (opts.labels[label.val]) {
28217
+ labelPref = opts.labels[label.val];
28150
28218
  }
28151
28219
  if (labelPref === "ignore") {
28152
28220
  return;
@@ -28165,9 +28233,9 @@ var ModerationCauseAccumulator = class {
28165
28233
  }
28166
28234
  this.causes.push({
28167
28235
  type: "label",
28236
+ source: isSelf || !labeler ? { type: "user" } : { type: "labeler", labeler: labeler.labeler },
28168
28237
  label,
28169
28238
  labelDef,
28170
- labeler: labelerSettings.labeler,
28171
28239
  setting: labelPref,
28172
28240
  priority
28173
28241
  });