@model-match/api 3.76.0 → 3.78.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.
@@ -7786,6 +7786,334 @@ var SavedFilters = class {
7786
7786
  });
7787
7787
  }
7788
7788
  };
7789
+ var Studio = class {
7790
+ /**
7791
+ * Tables you can query in Studio, with their columns
7792
+ *
7793
+ * Everything a Studio question can read: the market tables (recorded mortgage loans, home listings and sales), the result tables of your organization's own saved jobs, the files your organization uploaded (`upload_…`) and your organization's CRM (`crm_…`: the lists shared with the whole organization and the records in them, refreshed about every 15 minutes; they join to market data on NMLS ids). Each table lists its columns with a type and a plain-language description, and notes worth reading before writing SQL. `limits` says how many rows an answer can carry and how long a question may run; `guidance` says how to write SQL that works here. `notes` carries anything worth telling the user about the catalog itself, such as why there are no CRM tables yet. Read this before the first question in a conversation. Free.
7794
+ */
7795
+ static getStudioCatalog(options) {
7796
+ return (options?.client ?? client).get({
7797
+ security: [{
7798
+ name: "x-api-key",
7799
+ type: "apiKey"
7800
+ }, {
7801
+ scheme: "bearer",
7802
+ type: "http"
7803
+ }],
7804
+ url: "/v1/studio/catalog",
7805
+ ...options
7806
+ });
7807
+ }
7808
+ /**
7809
+ * Your organization's saved jobs
7810
+ *
7811
+ * Every job your organization has saved, each with its schedule, when it next runs, the table its result is in, and how its last run went. Free.
7812
+ */
7813
+ static listStudioJobs(options) {
7814
+ return (options?.client ?? client).get({
7815
+ security: [{
7816
+ name: "x-api-key",
7817
+ type: "apiKey"
7818
+ }, {
7819
+ scheme: "bearer",
7820
+ type: "http"
7821
+ }],
7822
+ url: "/v1/studio/jobs",
7823
+ ...options
7824
+ });
7825
+ }
7826
+ /**
7827
+ * Save a question as a job
7828
+ *
7829
+ * Save a SQL question to run again: on a schedule (`daily`, `weekly`) or only when asked (`manual`). Each run stores its result as a table named after the job, which later questions — and later jobs — can query like any other table. Name the `keys` (the columns that identify one row) to get 'what changed since the last run', and add `alerts` to flag new rows, removed rows or a number crossing a threshold. The SQL is checked when the job is saved: an unknown table or column, or a key that is not in the result, is refused here rather than at the first run. Saving does not run the job. Saving is free; each run that succeeds costs 10 credits, including the runs a `daily` or `weekly` schedule starts.
7830
+ */
7831
+ static createStudioJob(options) {
7832
+ return (options.client ?? client).post({
7833
+ security: [{
7834
+ name: "x-api-key",
7835
+ type: "apiKey"
7836
+ }, {
7837
+ scheme: "bearer",
7838
+ type: "http"
7839
+ }],
7840
+ url: "/v1/studio/jobs",
7841
+ ...options,
7842
+ headers: {
7843
+ "Content-Type": "application/json",
7844
+ ...options.headers
7845
+ }
7846
+ });
7847
+ }
7848
+ /**
7849
+ * Delete a job and its results
7850
+ *
7851
+ * Delete a saved job, its run history and its result tables. Questions and jobs that read its table stop working. Free.
7852
+ */
7853
+ static deleteStudioJob(options) {
7854
+ return (options.client ?? client).delete({
7855
+ security: [{
7856
+ name: "x-api-key",
7857
+ type: "apiKey"
7858
+ }, {
7859
+ scheme: "bearer",
7860
+ type: "http"
7861
+ }],
7862
+ url: "/v1/studio/jobs/{name}",
7863
+ ...options
7864
+ });
7865
+ }
7866
+ /**
7867
+ * One job: its runs, what changed, and where its result is
7868
+ *
7869
+ * A saved job with its recent runs (newest first), what changed in the latest successful run since the one before it, the alert rules that matched, and `result.table` — the table to query for its rows. Poll this after starting a run that answered `running`. Free.
7870
+ */
7871
+ static getStudioJob(options) {
7872
+ return (options.client ?? client).get({
7873
+ security: [{
7874
+ name: "x-api-key",
7875
+ type: "apiKey"
7876
+ }, {
7877
+ scheme: "bearer",
7878
+ type: "http"
7879
+ }],
7880
+ url: "/v1/studio/jobs/{name}",
7881
+ ...options
7882
+ });
7883
+ }
7884
+ /**
7885
+ * Run a job now
7886
+ *
7887
+ * Run a saved job now. Answers `200` with the finished run (its row count, what changed and any alerts) when it ends within a few seconds; otherwise `202` with `status: running`, and the run carries on — read the job to see how it ended. A run that fails answers `422` with `code: job_failed` and the reason. One job runs at a time per organization. 10 credits for a run that succeeds; a failed run is free. A run that has succeeded by the time this returns is charged now (`credits.charged`, with `credits.remaining`). One still running is charged when it finishes successfully: `credits.charged` is 0 and `credits.pending` says what it will cost.
7888
+ */
7889
+ static runStudioJob(options) {
7890
+ return (options.client ?? client).post({
7891
+ security: [{
7892
+ name: "x-api-key",
7893
+ type: "apiKey"
7894
+ }, {
7895
+ scheme: "bearer",
7896
+ type: "http"
7897
+ }],
7898
+ url: "/v1/studio/jobs/{name}/run",
7899
+ ...options
7900
+ });
7901
+ }
7902
+ /**
7903
+ * Your organization's models
7904
+ *
7905
+ * Every model your organization has: its status, what it predicts, the data points it uses, its report card and where its scores are. Only your organization's models are listed. Listing is free; a model that has just finished is charged for here if this is the first call to see it (`credits`), exactly as getStudioModel would.
7906
+ */
7907
+ static listStudioModels(options) {
7908
+ return (options?.client ?? client).get({
7909
+ security: [{
7910
+ name: "x-api-key",
7911
+ type: "apiKey"
7912
+ }, {
7913
+ scheme: "bearer",
7914
+ type: "http"
7915
+ }],
7916
+ url: "/v1/studio/models",
7917
+ ...options
7918
+ });
7919
+ }
7920
+ /**
7921
+ * Create a prediction model and start training it
7922
+ *
7923
+ * Define a model — what to predict, for whom, in which state, and the data points to use — and start training it. It answers at once with `status: training`; training takes a few minutes, so read the model with getStudioModel until it is `ready` or `refused`. `features` is the heart of it: the data points the person believes matter. Their own knowledge can be data points too — columns of their uploaded outcomes table such as a lead source or a rating their team gives. To learn from their own results instead of a market outcome, pass `outcomeSource` (an uploaded table with a home, a date and what happened on every row); that usually helps most. Everything a model learns from is taken strictly before each case's date, and a data point that could show it the answer is refused with the reason. To try a different list of data points, send the same `name` with `replace: true`, or a new name with `basedOn`: the new report card says what changed. A request that cannot work is refused now with a clear reason (`error`, `code`, and the numbers in `details`). One model trains at a time per organization, up to 10 models. 50 credits for a model that passes its checks, charged once when it has finished: by the first call that reads it or, if nobody does, on its own within about two hours. A model that is refused or fails is free.
7924
+ */
7925
+ static createStudioModel(options) {
7926
+ return (options.client ?? client).post({
7927
+ security: [{
7928
+ name: "x-api-key",
7929
+ type: "apiKey"
7930
+ }, {
7931
+ scheme: "bearer",
7932
+ type: "http"
7933
+ }],
7934
+ url: "/v1/studio/models",
7935
+ ...options,
7936
+ headers: {
7937
+ "Content-Type": "application/json",
7938
+ ...options.headers
7939
+ }
7940
+ });
7941
+ }
7942
+ /**
7943
+ * What a prediction model can be built from
7944
+ *
7945
+ * Everything needed to define a model: the outcomes that can be predicted, who can be scored (`populations`), the data points a model may use, grouped by theme, each with a line on why someone might believe it matters, the limits, and what a table of your own outcomes must contain. Call this first, show the themes, and ASK which data points the person believes matter: a model is trained on exactly their picks, and its report card tests that belief. Free.
7946
+ */
7947
+ static getStudioModelOptions(options) {
7948
+ return (options?.client ?? client).get({
7949
+ security: [{
7950
+ name: "x-api-key",
7951
+ type: "apiKey"
7952
+ }, {
7953
+ scheme: "bearer",
7954
+ type: "http"
7955
+ }],
7956
+ url: "/v1/studio/models/options",
7957
+ ...options
7958
+ });
7959
+ }
7960
+ /**
7961
+ * Delete a model, its report card and its scores, permanently
7962
+ *
7963
+ * Delete a model: the trained model, its report card and its scores table. The table leaves the catalog at once, and questions and jobs that read it stop working. A run in progress is stopped. This cannot be undone. Free.
7964
+ */
7965
+ static deleteStudioModel(options) {
7966
+ return (options.client ?? client).delete({
7967
+ security: [{
7968
+ name: "x-api-key",
7969
+ type: "apiKey"
7970
+ }, {
7971
+ scheme: "bearer",
7972
+ type: "http"
7973
+ }],
7974
+ url: "/v1/studio/models/{name}",
7975
+ ...options
7976
+ });
7977
+ }
7978
+ /**
7979
+ * A model: its status and its report card
7980
+ *
7981
+ * The model and, once training has finished, its report card (`card`). Read the card as it is written. It says how many past cases the model learned from and was tested on; the lift (`in the top 10% of the list, X of every 100 had the outcome, against Y at random and Z for the best simple rule`); three checks, each passed or not; how much each chosen data point mattered; how the person's picks compare with using every data point; and the caveats. Never promise accuracy, and never call a score a probability unless `card.calibration.calibrated` is true (then `estimatedChance` is an estimate from past cases). `status: refused` means the model is not dependable enough to publish: `card.refusal.reason` says why and `card.refusal.whatWouldHelp` what to try; a refused model has no scores. When `scores` is not null, query `scores.table` with runStudioQuery: one row per home with `rank`, `percentile`, `score`, `topReason`, and `propertyId` to join to `loans` and `sales`. Reading is free. 50 credits for a model that passes its checks, charged once when it has finished: by the first call that reads it or, if nobody does, on its own within about two hours. A model that is refused or fails is free. 10 credits for refreshed scores, charged once, the same way (a scheduled refresh too). The charge is reported in `credits`.
7982
+ */
7983
+ static getStudioModel(options) {
7984
+ return (options.client ?? client).get({
7985
+ security: [{
7986
+ name: "x-api-key",
7987
+ type: "apiKey"
7988
+ }, {
7989
+ scheme: "bearer",
7990
+ type: "http"
7991
+ }],
7992
+ url: "/v1/studio/models/{name}",
7993
+ ...options
7994
+ });
7995
+ }
7996
+ /**
7997
+ * Refresh a model's scores with the latest data
7998
+ *
7999
+ * Score the model's population again as of today, with the trained model as it is. The current scores stay queryable until the new ones are ready; read the model with getStudioModel to see when (`refresh` goes back to null and `scores.asOf` moves). Pass `retrain: true` to also train it again on the latest data (the same data points, a fresh report card; if it no longer passes its checks it becomes `refused` and its scores are taken down). A model with a `weekly` or `monthly` schedule is refreshed on its own. 10 credits for refreshed scores, charged once, the same way (a scheduled refresh too). 50 credits for a model that passes its checks, charged once when it has finished: by the first call that reads it or, if nobody does, on its own within about two hours. A model that is refused or fails is free.
8000
+ */
8001
+ static refreshStudioModel(options) {
8002
+ return (options.client ?? client).post({
8003
+ security: [{
8004
+ name: "x-api-key",
8005
+ type: "apiKey"
8006
+ }, {
8007
+ scheme: "bearer",
8008
+ type: "http"
8009
+ }],
8010
+ url: "/v1/studio/models/{name}/refresh",
8011
+ ...options,
8012
+ headers: {
8013
+ "Content-Type": "application/json",
8014
+ ...options.headers
8015
+ }
8016
+ });
8017
+ }
8018
+ /**
8019
+ * Answer one question with SQL
8020
+ *
8021
+ * Run one read-only SQL SELECT over the tables in the catalog and get the rows back. Use it for questions the list and analytics routes cannot answer in one call: a ranking across every company or agent in a market, a join between loans and sales, a custom roll-up. The data is stored by state: filter by `state` (and a date range) whenever the question allows, and aggregate in SQL instead of fetching rows. `rows` carries up to `limit` rows (default 200, at most 1000); `rowCount` is always the full count and `truncated` says when there are more. A question that runs too long is stopped with `timeout`: narrow it, or save it as a job. Only tables in the catalog can be read; nothing can be written. 5 credits per answered question; a refused or failed question is free. `credits` in the answer says what this question was charged and how many credits are left.
8022
+ */
8023
+ static runStudioQuery(options) {
8024
+ return (options.client ?? client).post({
8025
+ security: [{
8026
+ name: "x-api-key",
8027
+ type: "apiKey"
8028
+ }, {
8029
+ scheme: "bearer",
8030
+ type: "http"
8031
+ }],
8032
+ url: "/v1/studio/query",
8033
+ ...options,
8034
+ headers: {
8035
+ "Content-Type": "application/json",
8036
+ ...options.headers
8037
+ }
8038
+ });
8039
+ }
8040
+ /**
8041
+ * Your organization's uploads
8042
+ *
8043
+ * Every file your organization has uploaded: its name, the table it is queried as, its columns and row count, when it was uploaded and by whom, and its status. Only your organization's uploads are listed; no other organization can see or query them. Free.
8044
+ */
8045
+ static listStudioUploads(options) {
8046
+ return (options?.client ?? client).get({
8047
+ security: [{
8048
+ name: "x-api-key",
8049
+ type: "apiKey"
8050
+ }, {
8051
+ scheme: "bearer",
8052
+ type: "http"
8053
+ }],
8054
+ url: "/v1/studio/uploads",
8055
+ ...options
8056
+ });
8057
+ }
8058
+ /**
8059
+ * Start an upload: get a URL to send a file to
8060
+ *
8061
+ * Turn a file of your own data — leads, closed and lost loans, a client list — into a table only your organization can query and join to the market tables. This is step one of three: it reserves the name and answers with `uploadUrl`. Step two: send the file to `uploadUrl` with HTTP PUT (the file's bytes as the body; it must be exactly `sizeBytes` long). Step three: call complete. Files can be CSV, TSV, Excel (.xlsx) or Parquet, up to 100 MB, 2,000,000 rows and 200 columns; an organization can keep 25 uploads and 1 GB in total. The table will be `upload_<name>`. Asking again for a name whose file never arrived replaces the earlier request. Free.
8062
+ */
8063
+ static createStudioUpload(options) {
8064
+ return (options.client ?? client).post({
8065
+ security: [{
8066
+ name: "x-api-key",
8067
+ type: "apiKey"
8068
+ }, {
8069
+ scheme: "bearer",
8070
+ type: "http"
8071
+ }],
8072
+ url: "/v1/studio/uploads",
8073
+ ...options,
8074
+ headers: {
8075
+ "Content-Type": "application/json",
8076
+ ...options.headers
8077
+ }
8078
+ });
8079
+ }
8080
+ /**
8081
+ * Delete an upload and its table, permanently
8082
+ *
8083
+ * Delete an upload: its table, the rows that were read from the file, and its record. It leaves the catalog at once, and questions and jobs that read the table stop working. This cannot be undone — to get the table back, upload the file again. Free.
8084
+ */
8085
+ static deleteStudioUpload(options) {
8086
+ return (options.client ?? client).delete({
8087
+ security: [{
8088
+ name: "x-api-key",
8089
+ type: "apiKey"
8090
+ }, {
8091
+ scheme: "bearer",
8092
+ type: "http"
8093
+ }],
8094
+ url: "/v1/studio/uploads/{name}",
8095
+ ...options
8096
+ });
8097
+ }
8098
+ /**
8099
+ * Finish an upload: turn the file into a table
8100
+ *
8101
+ * Call this after the file has been sent to the upload URL. The file is read into the table `upload_<name>`, and the answer says what it holds: `columns` (names made safe for SQL, with a type each), `rowCount`, `warnings` (anything that was changed, skipped or kept as text — read them to the user) and `joinHints` (which columns line up with the market tables, with a join condition to copy). A small file answers `200` with `status: ready`. A large one answers `202` with `status: ingesting`: call complete again in a few seconds to collect the result. Calling it again on a ready upload is safe and answers with the same table. A file that cannot be used answers `422` and says why; create the upload again to send a corrected file. The original file is deleted once it has been read. Free.
8102
+ */
8103
+ static completeStudioUpload(options) {
8104
+ return (options.client ?? client).post({
8105
+ security: [{
8106
+ name: "x-api-key",
8107
+ type: "apiKey"
8108
+ }, {
8109
+ scheme: "bearer",
8110
+ type: "http"
8111
+ }],
8112
+ url: "/v1/studio/uploads/{name}/complete",
8113
+ ...options
8114
+ });
8115
+ }
8116
+ };
7789
8117
  //#endregion
7790
8118
  //#region src/index.ts
7791
8119
  /**
@@ -7836,4 +8164,4 @@ function createClient(config = {}) {
7836
8164
  };
7837
8165
  }
7838
8166
  //#endregion
7839
- export { client as C, Signals as S, Realtime as _, Branches as a, SavedFilters as b, Integrations as c, Locations as d, Market as f, Properties as g, Originators as h, Alerts as i, Lenders as l, Offices as m, createClient as n, Companies as o, Me as p, Agents as r, Crm as s, createApiClient as t, Loans as u, Related as v, Search as x, Sales as y };
8167
+ export { Studio as C, Signals as S, Realtime as _, Branches as a, SavedFilters as b, Integrations as c, Locations as d, Market as f, Properties as g, Originators as h, Alerts as i, Lenders as l, Offices as m, createClient as n, Companies as o, Me as p, Agents as r, Crm as s, createApiClient as t, Loans as u, Related as v, client as w, Search as x, Sales as y };