@singi-labs/sifa-sdk 0.12.69 → 0.12.71

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.
@@ -2857,19 +2857,140 @@ function useRemoveOrgNotificationEmail(options) {
2857
2857
  ...options
2858
2858
  });
2859
2859
  }
2860
+ function maxGraphemes(max) {
2861
+ return (value) => {
2862
+ const segmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
2863
+ let count = 0;
2864
+ for (const _ of segmenter.segment(value)) {
2865
+ count++;
2866
+ if (count > max) return false;
2867
+ }
2868
+ return true;
2869
+ };
2870
+ }
2871
+ var didSchema = z.string().regex(/^did:[a-z]+:[a-zA-Z0-9._:%-]+$/, "Invalid DID");
2872
+ var datetimeSchema = z.string().datetime({ offset: true });
2873
+ var partialDateSchema = z.string().regex(/^\d{4}(-\d{2}(-\d{2}(T.+)?)?)?$/, "Expected YYYY, YYYY-MM, YYYY-MM-DD, or a datetime");
2874
+ var atUriSchema = z.string().regex(/^at:\/\/[^\s]+$/, "Invalid AT-URI");
2875
+ var cidSchema = z.string().regex(/^(Qm[1-9A-HJ-NP-Za-km-z]{44}|b[A-Za-z0-9+/=]+)$/, "Invalid CID");
2876
+ z.string().regex(/^[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*$/, "Invalid BCP 47 language tag");
2877
+ var uriSchema = z.string().url();
2878
+ var strongRefSchema = z.object({
2879
+ uri: atUriSchema,
2880
+ cid: cidSchema
2881
+ });
2882
+ z.object({
2883
+ uri: atUriSchema
2884
+ });
2885
+ var externalRecordRefSchema = z.object({
2886
+ uri: atUriSchema,
2887
+ cid: cidSchema.optional()
2888
+ });
2889
+ var selfLabelsSchema = z.object({
2890
+ $type: z.literal("com.atproto.label.defs#selfLabels").optional(),
2891
+ values: z.array(z.object({ val: z.string() }))
2892
+ });
2893
+ var projectMemberRefSchema = z.object({
2894
+ did: didSchema,
2895
+ role: z.string().optional(),
2896
+ title: z.string().refine(maxGraphemes(128)).max(1280).optional()
2897
+ });
2898
+ z.object({
2899
+ name: z.string().min(1).refine(maxGraphemes(256)).max(2560),
2900
+ description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
2901
+ url: uriSchema.optional(),
2902
+ members: z.array(projectMemberRefSchema).max(50).optional(),
2903
+ /**
2904
+ * The canonical `id.sifa.project.self` this personal entry corresponds to.
2905
+ * A composition link. For the same project recorded on someone else's
2906
+ * profile, see `sameAs`.
2907
+ */
2908
+ projectRef: strongRefSchema.optional(),
2909
+ /**
2910
+ * The same project as recorded on another person's profile. Each side stays
2911
+ * its own record; this only says the two describe one thing. Resolves by
2912
+ * AT-URI, since they will keep editing their copy.
2913
+ */
2914
+ sameAs: externalRecordRefSchema.optional(),
2915
+ position: strongRefSchema.optional(),
2916
+ startedAt: partialDateSchema.optional(),
2917
+ endedAt: partialDateSchema.optional(),
2918
+ labels: selfLabelsSchema.optional(),
2919
+ createdAt: datetimeSchema
2920
+ });
2921
+
2922
+ // src/schemas/profile-involvement.ts
2923
+ var ArtifactLinkSchema = z.object({
2924
+ url: uriSchema,
2925
+ kind: z.string().optional(),
2926
+ label: z.string().refine(maxGraphemes(200)).max(2e3).optional()
2927
+ }).passthrough();
2928
+ z.object({
2929
+ kind: z.string(),
2930
+ upstream: z.string().refine(maxGraphemes(256)).max(2560).optional(),
2931
+ upstreamDid: didSchema.optional(),
2932
+ upstreamUrl: uriSchema.optional(),
2933
+ role: z.string().refine(maxGraphemes(256)).max(2560).optional(),
2934
+ description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
2935
+ startedAt: partialDateSchema.optional(),
2936
+ endedAt: partialDateSchema.optional(),
2937
+ links: z.array(ArtifactLinkSchema).max(50).optional(),
2938
+ // Portable org entity identifier (Wikidata/ROR/LEI URI) from the resolver
2939
+ // typeahead, constrained to http(s) so a script scheme is never a valid ref.
2940
+ entityRef: z.string().url().refine((s) => /^https?:\/\//i.test(s), { message: "entityRef must be an http(s) URL" }).max(2048).optional(),
2941
+ // community.lexicon.location.address — validated at the app layer.
2942
+ location: z.unknown().optional(),
2943
+ // id.sifa.defs#skillRef references (at-uri to a skill record in the same repo).
2944
+ skills: z.array(z.object({ uri: z.string() })).max(50).optional(),
2945
+ labels: selfLabelsSchema.optional(),
2946
+ collaborators: z.array(projectMemberRefSchema).max(50).optional(),
2947
+ sameAs: externalRecordRefSchema.optional(),
2948
+ createdAt: datetimeSchema
2949
+ }).passthrough();
2950
+
2951
+ // src/schemas/profile-investment.ts
2952
+ var entityRefField = z.string().url().refine((s) => /^https?:\/\//i.test(s), { message: "entityRef must be an http(s) URL" }).max(2048).optional();
2953
+ var InvestmentAmountSchema = z.object({
2954
+ /** Whole major currency units (euros, not cents). Cheque sizes are round numbers. */
2955
+ value: z.number().int().min(0),
2956
+ /** ISO 4217 three-letter code, uppercase. */
2957
+ currency: z.string().length(3)
2958
+ });
2959
+ var PROFILE_INVESTMENT_NSID = "id.sifa.profile.investment";
2960
+ z.object({
2961
+ /** For a limited-partner entry this names the fund, not a portfolio company. */
2962
+ company: z.string().min(1).refine(maxGraphemes(256)).max(2560),
2963
+ companyDid: didSchema.optional(),
2964
+ entityRef: entityRefField,
2965
+ role: z.string().optional(),
2966
+ stage: z.string().optional(),
2967
+ status: z.string().optional(),
2968
+ /** The vehicle the capital went through. Absent for a cheque in the person's own name. */
2969
+ via: z.string().refine(maxGraphemes(256)).max(2560).optional(),
2970
+ viaDid: didSchema.optional(),
2971
+ viaEntityRef: entityRefField,
2972
+ /**
2973
+ * Optional and empty by default. Cheque size is a personal financial disclosure,
2974
+ * and clients must not prompt for it.
2975
+ */
2976
+ amount: InvestmentAmountSchema.optional(),
2977
+ startedAt: partialDateSchema.optional(),
2978
+ endedAt: partialDateSchema.optional(),
2979
+ description: z.string().refine(maxGraphemes(5e3)).max(5e4).optional(),
2980
+ links: z.array(ArtifactLinkSchema).max(50).optional(),
2981
+ labels: selfLabelsSchema.optional(),
2982
+ createdAt: datetimeSchema
2983
+ }).passthrough();
2860
2984
 
2861
2985
  // src/query/fetchers/investments.ts
2862
2986
  function createInvestment(config, data, options = {}) {
2863
- return apiWriteCreate(config, "/api/profile/investment", data, options);
2987
+ return createRecord(config, PROFILE_INVESTMENT_NSID, data, options);
2864
2988
  }
2865
2989
  function updateInvestment(config, rkey, data, options = {}) {
2866
- return apiWrite(config, `/api/profile/investment/${encodeURIComponent(rkey)}`, "PUT", {
2867
- body: data,
2868
- ...options
2869
- });
2990
+ return updateRecord(config, PROFILE_INVESTMENT_NSID, rkey, data, options);
2870
2991
  }
2871
2992
  function deleteInvestment(config, rkey, options = {}) {
2872
- return apiWrite(config, `/api/profile/investment/${encodeURIComponent(rkey)}`, "DELETE", options);
2993
+ return deleteRecord(config, PROFILE_INVESTMENT_NSID, rkey, options);
2873
2994
  }
2874
2995
 
2875
2996
  // src/query/hooks/use-investment-mutations.ts